Zelda Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2023-11-03 17:54:56
Exec Total Coverage
Lines: 8544 12257 69.7%
Functions: 325 397 81.9%
Branches: 6715 13680 49.1%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 extern particle_list particles;
26
27 extern FFScript FFCore;
28 extern ZModule zcm;
29 extern HeroClass Hero;
30 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
31
32 int32_t repaircharge=0;
33 bool adjustmagic=false;
34 bool learnslash=false;
35 int32_t wallm_load_clk=0;
36 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
37 int32_t vhead=0;
38 int32_t guycarryingitem=0;
39
40 char *guy_string[eMAXGUYS];
41
42 void never_return(int32_t index);
43 void playLevelMusic();
44
45 // If an enemy is this far out of the playing field, just remove it.
46 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
47 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 648969 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 648969 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 648702 times.
648969 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648702 times.
648702 if (c < 0)
57 c -= val / 2;
58 648702 else c += (val/2);
59 648702 }
60 648969 c -= c % val;
61 648969 coord = c;
62 648969 }
63
64 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
65 {
66 return
67 (
68 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
69 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
70 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
71 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
72 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
73 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
74 );
75 }
76
77 namespace
78 {
79 int32_t trapConstantHorizontalID;
80 int32_t trapConstantVerticalID;
81 int32_t trapLOSHorizontalID;
82 int32_t trapLOSVerticalID;
83 int32_t trapLOS4WayID;
84
85 int32_t cornerTrapID;
86 int32_t centerTrapID;
87
88 int32_t rockID;
89 int32_t zoraID;
90 int32_t statueID;
91 }
92
93 122 void identifyCFEnemies()
94 {
95 122 trapConstantHorizontalID=-1;
96 122 trapConstantVerticalID=-1;
97 122 trapLOSHorizontalID=-1;
98 122 trapLOSVerticalID=-1;
99 122 trapLOS4WayID=-1;
100 122 cornerTrapID=-1;
101 122 centerTrapID=-1;
102 122 rockID=-1;
103 122 zoraID=-1;
104 122 statueID=-1;
105
106
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 122 times.
62586 for(int32_t i=0; i<eMAXGUYS; i++)
107 {
108
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 62343 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
62464 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
109 121 trapLOSHorizontalID=i;
110
4/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 62339 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
111 122 trapLOSVerticalID=i;
112
3/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 62342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
113 122 trapLOS4WayID=i;
114
3/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 62342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
115 122 trapConstantHorizontalID=i;
116
3/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 62342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
117 122 trapConstantVerticalID=i;
118
119
3/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 62342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
120 122 cornerTrapID=i;
121
3/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 62342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
122 122 centerTrapID=i;
123
124
3/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 62342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
125 122 rockID=i;
126
4/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 62337 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
127 122 zoraID=i;
128
129
4/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 62339 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 122 times.
62464 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
130 122 statueID=i;
131 62464 }
132 122 }
133
134 25 int32_t random_layer_enemy()
135 {
136 25 int32_t cnt=count_layer_enemies();
137
138
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
139 {
140 return eNONE;
141 }
142
143 25 int32_t ret=zc_oldrand()%cnt;
144 25 cnt=0;
145
146
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
147 {
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
149 {
150 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
151
152
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
153 {
154
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
155 {
156
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
157 {
158 25 return layerscreen->enemy[j];
159 }
160
161 102 ++cnt;
162 102 }
163 102 }
164 }
165 }
166
167 return eNONE;
168 25 }
169
170 39 int32_t count_layer_enemies()
171 {
172 39 int32_t cnt=0;
173
174
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
175 {
176
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
177 {
178 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
179
180
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
181 {
182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
183 {
184 390 ++cnt;
185 390 }
186 390 }
187 39 }
188 234 }
189
190 39 return cnt;
191 }
192
193 145542 int32_t hero_on_wall()
194 {
195 145542 zfix lx = Hero.getX();
196 145542 zfix ly = Hero.getY();
197
198
199 //zprint2("hero_on_wall x is: %d\n", lx);
200 //zprint2("hero_on_wall y is: %d\n", ly);
201
202
4/4
✓ Branch 0 taken 135889 times.
✓ Branch 1 taken 9653 times.
✓ Branch 2 taken 4526 times.
✓ Branch 3 taken 131363 times.
145542 if(lx>=48 && lx<=192)
203 {
204
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 131211 times.
131363 if(ly==32) return up+1;
205
206
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 131051 times.
131211 if(ly==128) return down+1;
207 131051 }
208
209
4/4
✓ Branch 0 taken 134471 times.
✓ Branch 1 taken 10759 times.
✓ Branch 2 taken 11441 times.
✓ Branch 3 taken 123030 times.
145230 if(ly>=48 && ly<=112)
210 {
211
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 122898 times.
123030 if(lx==32) return left+1;
212
213
2/2
✓ Branch 0 taken 122829 times.
✓ Branch 1 taken 69 times.
122898 if(lx==208) return right+1;
214 122829 }
215
216 145029 return 0;
217 145542 }
218
219 690683 bool tooclose(int32_t x,int32_t y,int32_t d)
220 {
221
2/2
✓ Branch 0 taken 511179 times.
✓ Branch 1 taken 179504 times.
690683 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
222 }
223
224 2107695 bool enemy::overpit(enemy *e)
225 {
226 // This function (and shadow_overpit) has been broken since it was written, and only
227 // checked the same diagonal of the hitbox, over and over again. The bug is because both
228 // loops used the same variable name.
229 // Checking literally every pixel seems like overkill, so for now let's continue to
230 // do the single diagonal but just once. That's why the outer loop is commented out.
231
232 // for ( int32_t q = 0; q < hxsz; ++q )
233 {
234
2/2
✓ Branch 0 taken 19856068 times.
✓ Branch 1 taken 2104527 times.
21960595 for ( int32_t q = 0; q < hit_height; ++q )
235 {
236 //check every pixel of the hitbox
237
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 19852900 times.
19856068 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
238 {
239 //if the hitbox is over a pit, we can't land
240 3168 return true;
241 }
242 19852900 }
243 }
244 2104527 return false;
245 2107695 }
246
247 4518811 bool enemy::shadow_overpit(enemy *e)
248 {
249 // for ( int32_t q = 0; q < hxsz; ++q )
250 {
251
2/2
✓ Branch 0 taken 66532458 times.
✓ Branch 1 taken 4514959 times.
71047417 for ( int32_t q = 0; q < hit_height; ++q )
252 {
253 //check every pixel of the hitbox
254
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 66528606 times.
66532458 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
255 {
256 //if the hitbox is over a pit, we can't land
257 3852 return true;
258 }
259 66528606 }
260 }
261 4514959 return false;
262 4518811 }
263
264 // Returns true iff a combo type or flag precludes enemy movement.
265 3797440 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
266 {
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3797440 times.
3797440 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
268 3797440 int32_t c = COMBOTYPE(dx,dy);
269
4/4
✓ Branch 0 taken 2492540 times.
✓ Branch 1 taken 1304900 times.
✓ Branch 2 taken 656349 times.
✓ Branch 3 taken 648551 times.
5102340 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
270
3/6
✓ Branch 0 taken 1291100 times.
✓ Branch 1 taken 2506340 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3797440 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_qr(qr_DROWN));
271
4/6
✓ Branch 0 taken 1326577 times.
✓ Branch 1 taken 2470863 times.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1326577 times.
✗ Branch 5 not taken.
7595483 return c==cPIT || c==cPITB || c==cPITC ||
272
4/6
✓ Branch 0 taken 1326577 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1237082 times.
✓ Branch 5 taken 89495 times.
1326577 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
273 // Block enemies type and block enemies flags
274
2/2
✓ Branch 0 taken 1325228 times.
✓ Branch 1 taken 1235733 times.
89495 combo_class_buf[c].block_enemies&1 ||
275
3/4
✓ Branch 0 taken 1325225 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1325225 times.
✗ Branch 3 not taken.
1325228 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
276
4/4
✓ Branch 0 taken 1324901 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 1324888 times.
✓ Branch 3 taken 13 times.
1325225 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
277 // Check for ladder-only combos which aren't dried water
278
4/4
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 1324294 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 5 times.
2649771 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
279 // Check for drownable water
280
4/4
✓ Branch 0 taken 103121 times.
✓ Branch 1 taken 1221762 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 101221 times.
1324883 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
281 1327180 }
282
283 // Returns true iff enemy is floating and blocked by a combo type or flag.
284 4618347 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
285 {
286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4618347 times.
4618347 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
287
4/4
✓ Branch 0 taken 2869530 times.
✓ Branch 1 taken 1748817 times.
✓ Branch 2 taken 1521446 times.
✓ Branch 3 taken 227371 times.
6367164 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
288
3/4
✓ Branch 0 taken 2879534 times.
✓ Branch 1 taken 1738813 times.
✓ Branch 2 taken 1738813 times.
✗ Branch 3 not taken.
6357160 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
289
2/2
✓ Branch 0 taken 557276 times.
✓ Branch 1 taken 4061071 times.
8679418 return ((special==spw_floater)&&
290
2/2
✓ Branch 0 taken 4054933 times.
✓ Branch 1 taken 6138 times.
4061071 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
291
1/2
✓ Branch 0 taken 4054933 times.
✗ Branch 1 not taken.
4054933 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
292
2/2
✓ Branch 0 taken 4054796 times.
✓ Branch 1 taken 137 times.
4054933 (MAPFLAG(dx,dy)==mfNOENEMY)||
293
1/2
✓ Branch 0 taken 4054796 times.
✗ Branch 1 not taken.
4054796 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
294
4/4
✓ Branch 0 taken 1240951 times.
✓ Branch 1 taken 2813845 times.
✓ Branch 2 taken 3939 times.
✓ Branch 3 taken 1237012 times.
8105653 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
295
2/2
✓ Branch 0 taken 2807382 times.
✓ Branch 1 taken 1243475 times.
4050857 (pit_blocks && ispitfall(dx,dy))));
296 4618347 }
297 // Returns true iff a combo type or flag precludes enemy movement.
298 242814 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
299 {
300 242814 int32_t c = COMBOTYPE(dx,dy);
301 242814 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
302
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 215489 times.
242814 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_qr(qr_DROWN);
303
4/6
✓ Branch 0 taken 242813 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242813 times.
✗ Branch 5 not taken.
922963 return c==cPIT || c==cPITB || c==cPITC ||
304
4/6
✓ Branch 0 taken 242813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 218778 times.
✓ Branch 5 taken 24035 times.
242813 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
305 // Block enemies type and block enemies flags
306
2/2
✓ Branch 0 taken 242703 times.
✓ Branch 1 taken 218668 times.
24035 combo_class_buf[c].block_enemies&1 ||
307
3/4
✓ Branch 0 taken 242555 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 242555 times.
✗ Branch 3 not taken.
242703 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
308
4/4
✓ Branch 0 taken 239059 times.
✓ Branch 1 taken 3496 times.
✓ Branch 2 taken 238787 times.
✓ Branch 3 taken 272 times.
242555 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
309 // Check for ladder-only combos which aren't dried water
310
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 238756 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
477574 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
311 // Check for drownable water
312
4/4
✓ Branch 0 taken 32351 times.
✓ Branch 1 taken 206436 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 8347 times.
238787 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
313 }
314
315 // Returns true iff enemy is floating and blocked by a combo type or flag.
316 115623 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
317 {
318
2/2
✓ Branch 0 taken 113300 times.
✓ Branch 1 taken 2323 times.
115623 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
319 115623 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115623 times.
231246 return ((special==spw_floater)&&
321
2/2
✓ Branch 0 taken 115621 times.
✓ Branch 1 taken 2 times.
115623 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
322
1/2
✓ Branch 0 taken 115621 times.
✗ Branch 1 not taken.
115621 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
323
2/2
✓ Branch 0 taken 115617 times.
✓ Branch 1 taken 4 times.
115621 (MAPFLAG(dx,dy)==mfNOENEMY)||
324
1/2
✓ Branch 0 taken 115617 times.
✗ Branch 1 not taken.
115617 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
325
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 113296 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
230984 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
326
2/2
✓ Branch 0 taken 113296 times.
✓ Branch 1 taken 2071 times.
115367 (pit_blocks && ispitfall(dx,dy))));
327 }
328
329 /**********************************/
330 /******* Enemy Base Class *******/
331 /**********************************/
332
333
4/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
116230 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
334 58115 {
335
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 x=X;
336
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 y=Y;
337 58115 id=Id;
338 58115 clk=Clk;
339
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 floor_y=y;
340 58115 ceiling=false;
341 58115 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
342 58115 grumble = movestatus = posframe = timer = ox = oy = 0;
343
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
58115 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
344 58115 did_armos=true;
345 58115 script_spawned=false;
346
347 58115 d = guysbuf + (id & 0xFFF);
348 58115 hp = d->hp;
349 58115 starting_hp = hp;
350 // cs = d->cset;
351 //d variables
352
353 58115 flags=d->flags;
354 58115 flags2=d->flags2;
355 58115 s_tile=d->s_tile; //secondary (additional) tile(s)
356 58115 family=d->family;
357 58115 dcset=d->cset;
358 58115 cs=dcset;
359
2/2
✓ Branch 0 taken 38815 times.
✓ Branch 1 taken 19300 times.
58115 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
360 58115 dp=d->dp;
361 58115 wdp=d->wdp;
362 58115 wpn=d->weapon;
363 58115 wpnsprite = d-> wpnsprite; //2.6 -Z
364 58115 rate=d->rate;
365 58115 hrate=d->hrate;
366
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dstep=d->step;
367 58115 homing=d->homing;
368 58115 dmisc1=d->misc1;
369 58115 dmisc2=d->misc2;
370 58115 dmisc3=d->misc3;
371 58115 dmisc4=d->misc4;
372 58115 dmisc5=d->misc5;
373 58115 dmisc6=d->misc6;
374 58115 dmisc7=d->misc7;
375 58115 dmisc8=d->misc8;
376 58115 dmisc9=d->misc9;
377 58115 dmisc10=d->misc10;
378 58115 dmisc11=d->misc11;
379 58115 dmisc12=d->misc12;
380 58115 dmisc13=d->misc13;
381 58115 dmisc14=d->misc14;
382 58115 dmisc15=d->misc15;
383 58115 dmisc16=d->misc16;
384 58115 dmisc17=d->misc17;
385 58115 dmisc18=d->misc18;
386 58115 dmisc19=d->misc19;
387 58115 dmisc20=d->misc20;
388 58115 dmisc21=d->misc21;
389 58115 dmisc22=d->misc22;
390 58115 dmisc23=d->misc23;
391 58115 dmisc24=d->misc24;
392 58115 dmisc25=d->misc25;
393 58115 dmisc26=d->misc26;
394 58115 dmisc27=d->misc27;
395 58115 dmisc28=d->misc28;
396 58115 dmisc29=d->misc29;
397 58115 dmisc30=d->misc30;
398 58115 dmisc31=d->misc31;
399 58115 dmisc32=d->misc32;
400
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 57679 times.
58115 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
401 {
402 57679 dmisc31 = dmisc32;
403 57679 dmisc32 = 0;
404 57679 }
405 58115 spr_shadow=d->spr_shadow;
406 58115 spr_death=d->spr_death;
407 58115 spr_spawn=d->spr_spawn;
408
409
2/2
✓ Branch 0 taken 2382715 times.
✓ Branch 1 taken 58115 times.
2440830 for(int32_t i=0; i<edefLAST255; i++)
410 2382715 defense[i]=d->defense[i];
411
412 58115 bgsfx=d->bgsfx;
413 58115 hitsfx=d->hitsfx;
414 58115 deadsfx=d->deadsfx;
415 58115 bosspal=d->bosspal;
416 58115 parent_script_UID = 0;
417
418 58115 frozentile = d->frozentile;
419
420 58115 frozencset = d->frozencset;
421 58115 frozenclock = 0;
422
2/2
✓ Branch 0 taken 581150 times.
✓ Branch 1 taken 58115 times.
639265 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
423
424
2/2
✓ Branch 0 taken 987955 times.
✓ Branch 1 taken 58115 times.
1046070 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
425 //firesfx = 0; //t.b.a -Z
426 58115 isCore = true; //t.b.a
427 58115 parentCore = 0; //t.b.a
428
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
429
430 58115 firesfx = d->firesfx;
431
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
432
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
433
434
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
435 58115 waitdraw = 0;
436
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
437
438
2/2
✓ Branch 0 taken 464920 times.
✓ Branch 1 taken 58115 times.
523035 for ( int32_t q = 0; q < 8; q++ )
439 {
440 464920 initD[q] = d->initD[q];
441 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
442 464920 weap_initiald[q] = d->weap_initiald[q];
443 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
444 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
445 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
446 464920 }
447
2/2
✓ Branch 0 taken 116230 times.
✓ Branch 1 taken 58115 times.
174345 for ( int32_t q = 0; q < 2; q++ )
448 {
449 116230 initA[q] = d->initA[q];
450 116230 weap_initiala[q] = d->weap_initiala[q];
451 116230 }
452
453 58115 stickclk = 0;
454 58115 submerged = false;
455 58115 didScriptThisFrame = false;
456 58115 ffcactivated = 0;
457 58115 hitdir = -1;
458 58115 dialogue_str = 0; //set by spawn flags.
459 58115 editorflags = d->editorflags; //set by Enemy Editor
460 //Set the drawing flag for this sprite.
461
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
462
463
464
2/2
✓ Branch 0 taken 49884 times.
✓ Branch 1 taken 8231 times.
58115 if(bosspal>-1)
465 {
466
1/2
✓ Branch 0 taken 8231 times.
✗ Branch 1 not taken.
8231 loadpalset(csBOSS,pSprite(bosspal));
467 8231 }
468
469
2/2
✓ Branch 0 taken 26009 times.
✓ Branch 1 taken 32106 times.
58115 if(bgsfx>-1)
470 {
471
1/2
✓ Branch 0 taken 26009 times.
✗ Branch 1 not taken.
26009 cont_sfx(bgsfx);
472 26009 }
473
474
2/2
✓ Branch 0 taken 38815 times.
✓ Branch 1 taken 19300 times.
58115 if(get_qr(qr_NEWENEMYTILES))
475 {
476 38815 o_tile=d->e_tile;
477 38815 frate = d->e_frate;
478 38815 }
479 else
480 {
481 19300 o_tile=d->tile;
482 19300 frate = d->frate;
483 }
484
485 58115 tile=0; //init to 0 here, but set it later.
486
487 58115 scripttile = -1;
488 58115 scriptflip = -1;
489 58115 do_animation = 1;
490 58115 immortal = false;
491 58115 noSlide = false;
492 58115 deathexstate = -1;
493
494 58115 hashero=false;
495
496 // If they forgot the invisibility flag, here's another failsafe:
497
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 55257 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2764 times.
58115 if(o_tile==0 && family!=eeSPINTILE)
498 2764 flags |= guy_invisible;
499
500 // step = d->step/100.0;
501 // To preserve the odd step values for Keese & Gleeok heads. -L
502
5/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6746 times.
✓ Branch 5 taken 51369 times.
✓ Branch 6 taken 6746 times.
✗ Branch 7 not taken.
58115 if(dstep==62.0) dstep+=0.5;
503
5/8
✓ Branch 0 taken 51369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 360 times.
✓ Branch 5 taken 51009 times.
✓ Branch 6 taken 360 times.
✗ Branch 7 not taken.
51369 else if(dstep==89) dstep-=1/9;
504
505
5/10
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58115 times.
✗ Branch 9 not taken.
58115 step = zslongToFix(dstep*100);
506
507
508 58115 item_set = d->item_set;
509 58115 grumble = d->grumble;
510
511
2/2
✓ Branch 0 taken 45387 times.
✓ Branch 1 taken 12728 times.
58115 if(frate == 0)
512 12728 frate = 256;
513
514 58115 leader = itemguy = dying = scored = false;
515 58115 canfreeze = count_enemy = true;
516 58115 mainguy = !(flags & guy_doesntcount);
517
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dir = zc_oldrand()&3;
518
519 //2.6 Enemy Editor Hit and TIle Sizes
520
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
521 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
522 // al_trace("Enemy txsz:%i\n", txsz);
523
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
527
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
528
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
529 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
532 {
533 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
534 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
535 }
536
537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
538
539 58115 SIZEflags = d->SIZEflags;
540
541
8/10
✓ Branch 0 taken 58027 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 58027 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
58115 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
542 1 wpn = 0;
543
544 //tile should never be 0 after init --Z (failsafe)
545
4/6
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57108 times.
✓ Branch 5 taken 1007 times.
58115 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
546
547 //Moveflags; for gravity and pit interaction
548 58115 moveflags = d->moveflags;
549
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50647 times.
✓ Branch 3 taken 7468 times.
58115 if(!can_pitfall(false))
550 {
551 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
552 7468 moveflags &= ~FLAG_CAN_PITFALL;
553 7468 moveflags &= ~FLAG_CAN_WATERDROWN;
554 7468 }
555
556 58115 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
557 58115 }
558
559 598 int32_t enemy::getScriptUID() { return script_UID; }
560 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
561 57970 enemy::~enemy()
562 57970 {
563
2/4
✓ Branch 0 taken 57970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57970 times.
✗ Branch 3 not taken.
57970 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
564
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 57966 times.
57970 if(hashero)
565 {
566
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Hero.setEaten(0);
567 4 hashero=false;
568 4 }
569 57970 }
570
571
572 bool enemy::is_move_paused()
573 {
574 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
575 }
576
577 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
578 {
579 int32_t yg = (special==spw_floater)?8:0;
580 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
581 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
582 if(input_x == -1000)
583 input_x = dx;
584 if(input_y == -1000)
585 input_y = dy;
586
587 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
588 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
589 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
590 return true;
591
592 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
593 {
594 if(ispitfall(dx,dy))
595 return true;
596 }
597
598 bool flying = false;
599 bool cansolid = false;
600 if(moveflags & FLAG_IGNORE_SOLIDITY)
601 cansolid = true;
602 switch(special)
603 {
604 case spw_clipbottomright:
605 if(dy>=128 || dx>=208) return true;
606 break;
607 case spw_clipright:
608 break; //if(input_x>=208) return true; break;
609
610 case spw_wizzrobe: // fall through
611 case spw_floater: // Special case for fliers and wizzrobes - hack!
612 {
613 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
614 {
615 if(dy < 32-yg || dy >= 144) return true;
616 if(dx < 32 || dx >= 224) return true;
617 }
618 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
619 return true;
620 cansolid = true;
621 flying = true;
622 }
623 }
624
625 dx &= ~7;
626 dy &= ~7;
627
628 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
629
630 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
631 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
632 //_walkflag code
633 mapscr *s1, *s2;
634 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
635 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
636
637 int32_t cpos=(dx>>4)+(dy&0xF0);
638 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
639 newcombo const& c = combobuf[ci];
640 newcombo const& c1 = combobuf[ci1];
641 newcombo const& c2 = combobuf[ci2];
642
643 int32_t b=1;
644 if(dx&8) b<<=2;
645 if(dy&8) b<<=1;
646
647 #define iwtr(cmb, x, y, shallow) \
648 (shallow \
649 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
650 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
651 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
652 bool wtr = iwtr(ci, dx, dy, false);
653 bool shwtr = iwtr(ci, dx, dy, true);
654 bool pit = ispitfall(dx,dy);
655
656 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
657 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
658 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
659 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
660 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
661
662 if(!cansolid)
663 {
664 int32_t cwalkflag = c.walk & 0xF;
665 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
666 if (s1)
667 {
668 if (c1.type == cBRIDGE)
669 {
670 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
671 {
672 int efflag = (c1.walk & 0xF0)>>4;
673 int newsolid = (c1.walk & 0xF);
674 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
675 }
676 else cwalkflag &= c1.walk;
677 }
678 else cwalkflag |= c1.walk & 0xF;
679 }
680 if (s2)
681 {
682 if (c2.type == cBRIDGE)
683 {
684 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
685 {
686 int efflag = (c2.walk & 0xF0)>>4;
687 int newsolid = (c2.walk & 0xF);
688 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
689 }
690 else cwalkflag &= c2.walk;
691 }
692 else cwalkflag |= c2.walk & 0xF;
693 }
694 if(cwalkflag & b)
695 return true;
696 }
697 if(needwtr || needshwtr || needpit)
698 {
699 bool ret = true;
700 if (needwtr && wtr) ret = false;
701 else if (needshwtr && shwtr) ret = false;
702 else if (needpit && pit) ret = false;
703 return ret;
704 }
705 else if(wtr && !canwtr)
706 return true;
707 else if(pit && !canpit)
708 return true;
709
710 return false;
711 }
712
713 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
714 {
715 if(!(dx || dy)) return true;
716 zfix bx = x+hxofs, by = y+hyofs; //left/top
717 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
718 if(!ign_sv && dy < 0) //check gravity
719 {
720 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
721 return false;
722 }
723
724 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
725
726 if(dx && !dy)
727 {
728 if(dx < 0)
729 {
730 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
731 int mx = (bx+dx).getFloor();
732 for(zfix ty = 0; by+ty < ry; ty += 8)
733 {
734 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
735 return false;
736 }
737 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
738 return false;
739 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
740 return false;
741 }
742 else
743 {
744 int mx = (rx+dx).getCeil();
745 int lx = mx-hit_width+1;
746 for(zfix ty = 0; by+ty < ry; ty += 8)
747 {
748 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
749 return false;
750 }
751 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
752 return false;
753 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
754 return false;
755 }
756 }
757 else if(dy && !dx)
758 {
759 if(dy < 0)
760 {
761 special = (special==spw_clipbottomright)?spw_none:special;
762 int my = (by+dy).getFloor();
763 for(zfix tx = 0; bx+tx < rx; tx += 8)
764 {
765 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
766 return false;
767 }
768 if(scr_walkflag(rx, my, special, up, bx, my, kb))
769 return false;
770 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
771 return false;
772 }
773 else
774 {
775 int my = (ry+dy).getCeil();
776 int ly = my-hit_height+1;
777 for(zfix tx = 0; bx+tx < rx; tx += 8)
778 {
779 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
780 return false;
781 }
782 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
783 return false;
784 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
785 return false;
786 }
787 }
788 else //! Untested, and currently unused.
789 {
790 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
791 }
792 return true;
793 }
794
795 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
796 {
797 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
798 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
799
800 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
801
802 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
803 return false;
804 for(zfix ty = 0; by+ty < ry; ty += 8)
805 {
806 for(zfix tx = 0; bx+tx < rx; tx += 8)
807 {
808 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
809 return false;
810 }
811 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
812 return false;
813 }
814 for(zfix tx = 0; bx+tx < rx; tx += 8)
815 {
816 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
817 return false;
818 }
819 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
820 return false;
821 return true;
822 }
823
824 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
825 {
826 auto oxsz = hit_width, oysz = hit_height;
827 if(nwid > -1) hit_width = nwid;
828 if(nhei > -1) hit_height = nhei;
829 bool ret = scr_canplace(dx,dy,special,kb);
830 hit_width = oxsz; hit_height = oysz;
831 return ret;
832 }
833
834 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
835 {
836 bool ret = true;
837 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
838 dy = 0;
839 const int scl = 2;
840 while(abs(dx) > scl || abs(dy) > scl)
841 {
842 if(abs(dx) > abs(dy))
843 {
844 int32_t tdx = dx.sign() * scl;
845 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
846 dx -= tdx;
847 else
848 {
849 if(earlyret) return false;
850 dx = tdx;
851 ret = false;
852 }
853 }
854 else
855 {
856 int32_t tdy = dy.sign() * scl;
857 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
858 dy -= tdy;
859 else
860 {
861 if(earlyret) return false;
862 dy = tdy;
863 ret = false;
864 }
865 }
866 }
867
868 if(dx)
869 {
870 if(scr_canmove(dx, 0, special, kb, ign_sv))
871 x += dx;
872 else
873 {
874 if(earlyret) return false;
875 ret = false;
876 int xsign = dx.sign();
877 while(scr_canmove(xsign, 0, special, kb, ign_sv))
878 {
879 x += xsign;
880 dx -= xsign;
881 }
882 if(dx)
883 {
884 dx.doDecBound(0,-9999, 0,9999);
885 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
886 if(scr_canmove(val, 0, special, kb, ign_sv))
887 {
888 retval = val;
889 return BSEARCH_CONTINUE_AWAY0;
890 }
891 else return BSEARCH_CONTINUE_TOWARD0;
892 });
893 x += dx;
894 }
895 }
896 }
897 if(dy)
898 {
899 if(scr_canmove(0, dy, special, kb, ign_sv))
900 y += dy;
901 else
902 {
903 if(earlyret) return false;
904 ret = false;
905 int ysign = dy.sign();
906 while(scr_canmove(0, ysign, special, kb, ign_sv))
907 {
908 y += ysign;
909 dy -= ysign;
910 }
911 if(dy)
912 {
913 dy.doDecBound(0,-9999, 0,9999);
914 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
915 if(scr_canmove(0, val, special, kb, ign_sv))
916 {
917 retval = val;
918 return BSEARCH_CONTINUE_AWAY0;
919 }
920 else return BSEARCH_CONTINUE_TOWARD0;
921 });
922 y += dy;
923 }
924 }
925 }
926 return ret;
927 }
928
929 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
930 {
931 static const zfix diagrate = zslongToFix(7071);
932 switch(NORMAL_DIR(dir))
933 {
934 case up:
935 return movexy(0, -px, special, kb, false, earlyret);
936 case down:
937 return movexy(0, px, special, kb, false, earlyret);
938 case left:
939 return movexy(-px, 0, special, kb, false, earlyret);
940 case right:
941 return movexy(px, 0, special, kb, false, earlyret);
942 case r_up:
943 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
944 case r_down:
945 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
946 case l_up:
947 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
948 case l_down:
949 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
950 }
951 return false;
952 }
953
954 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
955 {
956 double v = degrees.getFloat() * PI / 180.0;
957 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
958 return movexy(dx, dy, special, kb, false, earlyret);
959 }
960
961 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
962 {
963 zfix tx = x, ty = y;
964 bool ret = movexy(dx, dy, special, kb, false, true);
965 x = tx;
966 y = ty;
967 return ret;
968 }
969 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
970 {
971 zfix tx = x, ty = y;
972 bool ret = moveDir(dir, px, special, kb, true);
973 x = tx;
974 y = ty;
975 return ret;
976 }
977 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
978 {
979 zfix tx = x, ty = y;
980 bool ret = moveAtAngle(degrees, px, special, kb, true);
981 x = tx;
982 y = ty;
983 return ret;
984 }
985
986 // Handle pitfalls
987 21148762 bool enemy::do_falling(int32_t index)
988 {
989
2/2
✓ Branch 0 taken 21148620 times.
✓ Branch 1 taken 142 times.
21148762 if(fallclk > 0)
990 {
991
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
992
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
993 {
994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
995 ++fallclk; //force another frame of falling.... forever.
996
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
997 {
998
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
999 never_return(index);
1000
1001
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
1002 kill_em_all();
1003
1004 //leave_item(); //Don't drop items in pits!
1005 2 stop_bgsfx(index);
1006 2 return true;
1007 }
1008 else
1009 {
1010 2 try_death(true); //Force death
1011 2 ++fallclk; //force another frame of falling
1012 }
1013 2 }
1014
1015 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1016 140 cs = spr.csets & 0xF;
1017
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
1018
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
1019 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1020
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
1021 140 }
1022 21148760 return false;
1023 21148762 }
1024
1025 // Handle drowning in water
1026 21148620 bool enemy::do_drowning(int32_t index)
1027 {
1028
1/2
✓ Branch 0 taken 21148620 times.
✗ Branch 1 not taken.
21148620 if(drownclk > 0)
1029 {
1030 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1031 //!TODO: Drown SFX
1032 if(!--drownclk)
1033 {
1034 if(immortal) //Keep alive forever
1035 ++drownclk; //force another frame of falling.... forever.
1036 else if(dying) //Give 1 frame for script revival
1037 {
1038 if(flags&guy_neverret)
1039 never_return(index);
1040
1041 if(leader)
1042 kill_em_all();
1043
1044 //leave_item(); //Don't drop items in pits!
1045 stop_bgsfx(index);
1046 return true;
1047 }
1048 else
1049 {
1050 try_death(true); //Force death
1051 ++drownclk; //force another frame of falling
1052 }
1053 }
1054
1055 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1056 {
1057 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1058 cs = spr.csets & 0xF;
1059 int32_t fr = spr.frames ? spr.frames : 1;
1060 int32_t spd = spr.speed ? spr.speed : 1;
1061 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1062 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1063 }
1064 else
1065 {
1066 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1067 cs = spr.csets & 0xF;
1068 int32_t fr = spr.frames ? spr.frames : 1;
1069 int32_t spd = spr.speed ? spr.speed : 1;
1070 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1071 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1072 }
1073 }
1074 21148620 return false;
1075 21148620 }
1076
1077 // Supplemental animation code that all derived classes should call
1078 // as a return value for animate().
1079 // Handles the death animation and returns true when enemy is finished.
1080 21532885 bool enemy::Dead(int32_t index)
1081 {
1082
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21531056 times.
21532885 if(immortal)
1083 {
1084 1829 dying = false;
1085 1829 return false;
1086 }
1087
2/2
✓ Branch 0 taken 449834 times.
✓ Branch 1 taken 21081222 times.
21531056 if(dying)
1088 {
1089
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 449833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
449834 if(deathexstate > -1 && deathexstate < 32)
1090 {
1091 1 setxmapflag(1<<deathexstate);
1092 1 deathexstate = -1;
1093 1 }
1094 449834 --clk2;
1095
1096
4/4
✓ Branch 0 taken 445139 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 21421 times.
✓ Branch 3 taken 2961 times.
449834 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1097
2/2
✓ Branch 0 taken 24382 times.
✓ Branch 1 taken 420757 times.
445139 && hp>-1000) // not killed by ringleader
1098 21421 death_sfx();
1099
1100
2/2
✓ Branch 0 taken 425254 times.
✓ Branch 1 taken 24580 times.
449834 if(clk2==0)
1101 {
1102
2/2
✓ Branch 0 taken 24174 times.
✓ Branch 1 taken 406 times.
24580 if(flags&guy_neverret)
1103 406 never_return(index);
1104
1105
2/2
✓ Branch 0 taken 24523 times.
✓ Branch 1 taken 57 times.
24580 if(leader)
1106 57 kill_em_all();
1107
1108 24580 leave_item();
1109 24580 }
1110
1111 449834 stop_bgsfx(index);
1112 449834 return (clk2==0);
1113 }
1114
1115 21081222 return false;
1116 21532885 }
1117
1118 // Basic animation code that all derived classes should call.
1119 // The one with an index is the one that is called by
1120 // the guys sprite list; index is the enemy's index in the list.
1121 21148762 bool enemy::animate(int32_t index)
1122 {
1123
2/2
✓ Branch 0 taken 896465 times.
✓ Branch 1 taken 20252297 times.
21148762 if(sclk <= 0) hitdir = -1;
1124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148762 times.
21148762 if(switch_hooked)
1125 {
1126 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1127 {
1128 //Run its script
1129 if (!didScriptThisFrame)
1130 {
1131 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1132 {
1133 return 0; //Avoid NULLPO if this object deleted itself
1134 }
1135 }
1136 }
1137 return false;
1138 }
1139
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21148760 times.
21148762 if(do_falling(index)) return true;
1140
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 21148620 times.
21148760 else if(fallclk)
1141 {
1142 //clks
1143
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
1144 60 --hclk;
1145
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
1146 --stunclk;
1147
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
1148 --frozenclock;
1149
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
1150 {
1151 Hero.setX(x);
1152 Hero.setY(y);
1153 Hero.fallCombo = fallCombo;
1154 Hero.fallclk = fallclk;
1155 hashero = false; //Let Hero go if falling
1156 }
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!didScriptThisFrame)
1158 {
1159 140 run_script(MODE_NORMAL);
1160 140 }
1161 140 return false;
1162 }
1163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if(do_drowning(index)) return true;
1164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 else if(drownclk)
1165 {
1166 //clks
1167 if(hclk>0)
1168 --hclk;
1169 if(stunclk>0)
1170 --stunclk;
1171 if ( frozenclock > 0 )
1172 --frozenclock;
1173 if(hashero)
1174 {
1175 Hero.setX(x);
1176 Hero.setY(y);
1177 Hero.drownclk = drownclk;
1178 hashero = false; //Let Hero go if falling
1179 }
1180 if (!didScriptThisFrame)
1181 {
1182 run_script(MODE_NORMAL);
1183 }
1184 return false;
1185 }
1186 21148620 int32_t nx = real_x(x);
1187 21148620 int32_t ny = real_y(y);
1188
1189
4/4
✓ Branch 0 taken 15590435 times.
✓ Branch 1 taken 5558185 times.
✓ Branch 2 taken 3126427 times.
✓ Branch 3 taken 12464008 times.
21148620 if(ox!=nx || oy!=ny)
1190 {
1191 8684612 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1192 8684612 }
1193
1194 21148620 ox = nx;
1195 21148620 oy = ny;
1196
1197 // Maybe they fell off the bottom in sideview, or were moved by a script.
1198
1199 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1200
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21146791 times.
21148620 if ( immortal )
1201 {
1202 //skip, as it can go out of bounds, from immortality
1203 1829 }
1204
2/6
✓ Branch 0 taken 21146791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21146791 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21146791 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1205 {
1206 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1207 }
1208
9/10
✓ Branch 0 taken 20750698 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 21145786 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 21116075 times.
✓ Branch 5 taken 29711 times.
✓ Branch 6 taken 21116075 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 21116039 times.
21146791 else if ( (OUTOFBOUNDS) )
1209 {
1210 30752 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1211 30752 }
1212 //fall down
1213
6/6
✓ Branch 0 taken 13962695 times.
✓ Branch 1 taken 7185925 times.
✓ Branch 2 taken 7026915 times.
✓ Branch 3 taken 14121705 times.
✓ Branch 4 taken 338067 times.
✓ Branch 5 taken 6688848 times.
21148620 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 6385274 times.
6688848 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1220 {
1221 127235 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 127235 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 127235 y+=fall/100;
1242
2/2
✓ Branch 0 taken 109427 times.
✓ Branch 1 taken 17808 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1243 109427 fall += (zinit.gravity/100);
1244 }
1245 127235 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 267 do_fix(y, 8); //Fix position
1252 267 }
1253
1254 176339 fall = 0;
1255 }
1256 303574 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= (int32_t)zinit.terminalv)
1287 fall += (zinit.gravity/100);
1288 }
1289 }
1290 303574 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_FAKE_Z))
1294 {
1295
2/2
✓ Branch 0 taken 3220250 times.
✓ Branch 1 taken 3165024 times.
6385274 if(fakefall!=0)
1296 3165024 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 3165024 times.
✓ Branch 1 taken 3220250 times.
6385274 if(fakez<0)
1299 3165024 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3220250 times.
3220250 else if(fakefall <= (int32_t)zinit.terminalv)
1301 3220250 fakefall += (zinit.gravity/100);
1302
1303
5/6
✓ Branch 0 taken 6385274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3220250 times.
✓ Branch 3 taken 3165024 times.
✓ Branch 4 taken 3173265 times.
✓ Branch 5 taken 46985 times.
6385274 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 6385274 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_REAL_Z))
1306 {
1307
2/2
✓ Branch 0 taken 3486762 times.
✓ Branch 1 taken 2898512 times.
6385274 if(fall!=0)
1308 2898512 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 2892688 times.
✓ Branch 1 taken 3492586 times.
6385274 if(z<0)
1311 2892688 z = fall = 0;
1312
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 3487942 times.
3492586 else if(fall <= (int32_t)zinit.terminalv)
1313 3487942 fall += (zinit.gravity/100);
1314
1315
6/6
✓ Branch 0 taken 6379353 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 3486665 times.
✓ Branch 3 taken 2892688 times.
✓ Branch 4 taken 3439680 times.
✓ Branch 5 taken 46985 times.
6385274 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 6385274 }
1317
1318 }
1319 6688848 }
1320
4/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 5819008 times.
✓ Branch 3 taken 18007049 times.
21148620 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
1321 {
1322
8/10
✓ Branch 0 taken 6010270 times.
✓ Branch 1 taken 11996779 times.
✓ Branch 2 taken 6003285 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 6003285 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6010270 times.
✓ Branch 8 taken 6003285 times.
✓ Branch 9 taken 6003285 times.
18007049 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1323 {
1324 6003285 fallCombo = check_pits();
1325 6003285 }
1326 30013619 }
1327
3/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 8638509 times.
✓ Branch 2 taken 20752527 times.
✗ Branch 3 not taken.
12235162 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
1328 {
1329 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1330 {
1331 drownCombo = check_water();
1332 }
1333 }
1334
1335 29391036 runKnockback(); //scripted knockback handling
1336
1337 // clk is incremented here
1338
2/2
✓ Branch 0 taken 28255119 times.
✓ Branch 1 taken 1135917 times.
29391036 if(++clk >= frate)
1339 1135917 clk=0;
1340
1341 // hit and death handling
1342
2/2
✓ Branch 0 taken 28707305 times.
✓ Branch 1 taken 683731 times.
29391036 if(hclk>0)
1343 683731 --hclk;
1344
1345
2/2
✓ Branch 0 taken 28958644 times.
✓ Branch 1 taken 432392 times.
29391036 if(stunclk>0)
1346 432392 --stunclk;
1347
1/2
✓ Branch 0 taken 29391036 times.
✗ Branch 1 not taken.
29391036 if ( frozenclock > 0 )
1348 --frozenclock;
1349
1350
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 29384034 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
29391036 if(ceiling && z <= 0 && fakez <= 0)
1351 55 ceiling = false;
1352
1353 29391036 try_death();
1354
1355 29391036 scored=false;
1356
1357 29391036 ++c_clk;
1358
1359 //Run its script
1360
2/2
✓ Branch 0 taken 8242416 times.
✓ Branch 1 taken 21148620 times.
29391036 if (!didScriptThisFrame)
1361 {
1362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1363 {
1364 return 0; //Avoid NULLPO if this object deleted itself
1365 }
1366 21148620 }
1367
1368 // returns true when enemy is defeated
1369 29391036 return Dead(index);
1370 29391178 }
1371
1372 21572753 bool enemy::setSolid(bool set)
1373 {
1374
1/2
✓ Branch 0 taken 21572753 times.
✗ Branch 1 not taken.
21572753 bool actual = set && !isSubmerged();
1375 21572753 bool ret = solid_object::setSolid(actual);
1376 21572753 solid = set;
1377 21572753 return ret;
1378 }
1379 void enemy::doContactDamage(int32_t hdir)
1380 {
1381 Hero.hithero(guys.find(this), hdir);
1382 }
1383
1384 3278 void enemy::solid_push(solid_object *obj)
1385 {
1386
1/2
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
3278 if(obj == this) return; //can't push self
1387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
1388 3278 zfix dx, dy;
1389 3278 int32_t hdir = -1;
1390 3278 solid_push_int(obj,dx,dy,hdir,true);
1391
1392
2/4
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3278 times.
✗ Branch 3 not taken.
3278 if(!dx && !dy) return;
1393
1394 bool t = obj->getTempNonsolid();
1395 obj->setTempNonsolid(true);
1396
1397 int32_t ydir = dy > 0 ? down : up;
1398 int32_t xdir = dx > 0 ? right : left;
1399
1400 auto special = isflier(id) ? spw_floater : spw_none;
1401 if(!movexy(dx,dy,special,true,true))
1402 {
1403 //Crushed?
1404 }
1405
1406 obj->setTempNonsolid(t);
1407 3278 }
1408 3278 bool enemy::is_unpushable() const
1409 {
1410 3278 return isSubmerged();
1411 }
1412 3278 bool enemy::sideview_mode() const
1413 {
1414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3278 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
1415 }
1416
1417 2559 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1418 {
1419 2559 int32_t yg = (special==spw_floater)?8:0;
1420 2559 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1421
1422
8/10
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 613 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 613 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1948 times.
✓ Branch 9 taken 2561 times.
2559 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1423 3894 return true;
1424
1425 2561 bool isInDungeon = isdungeon();
1426
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2445 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
2561 if(isInDungeon || special==spw_wizzrobe)
1427 {
1428
7/8
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 1951 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 1462 times.
✓ Branch 6 taken 495 times.
✗ Branch 7 not taken.
2445 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1429 983 return true;
1430
1431
7/8
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 488 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 488 times.
✗ Branch 7 not taken.
1462 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1432
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
976 if(special!=spw_door) // walk in door way
1433 return true;
1434 488 }
1435
1436
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
604 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
1437 {
1438
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1439
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1440 return true;
1441 62 }
1442
1443
1/4
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
604 switch(special)
1444 {
1445 case spw_clipbottomright:
1446 if(dy>=128 || dx>=208) return true;
1447 break;
1448 case spw_clipright:
1449 break; //if(x>=208) return true; break;
1450
1451 case spw_wizzrobe: // fall through
1452 case spw_floater: // Special case for fliers and wizzrobes - hack!
1453 {
1454
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 488 times.
604 if(isInDungeon)
1455 {
1456
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dy < 32-yg || dy >= 144) return true;
1457
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dx < 32 || dx >= 224) return true;
1458 488 }
1459 604 return false;
1460 }
1461 }
1462
1463 dx&=(special==spw_halfstep)?(~7):(~15);
1464 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1465
1466 if(special==spw_water)
1467 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1468
1469 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1470 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1471 613 }
1472
1473 5149 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1474 {
1475 5149 bool kb = false;
1476 5149 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1477
1478
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5149 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5149 times.
5149 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1479 return true;
1480
1481
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 715 times.
5149 if(isdungeon())
1482 {
1483
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dy<32) || (dy>=144))
1484 return true;
1485
1486
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dx<32) || (dx>=224))
1487 return true;
1488 715 }
1489
1490
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
5149 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
1491 {
1492
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
10298 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1493
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
5149 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1494 return true;
1495 5149 }
1496
1497
1/2
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
5149 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1498 {
1499
3/4
✓ Branch 0 taken 1489 times.
✓ Branch 1 taken 3660 times.
✓ Branch 2 taken 1489 times.
✗ Branch 3 not taken.
6638 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1489 times.
1489 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1501 }
1502 else
1503 {
1504 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1505 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1506 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1507 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1508 }
1509 5149 }
1510
1511 19029446 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1512 {
1513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19029446 times.
19029446 if(moveflags & FLAG_USE_NEW_MOVEMENT)
1514 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1515 19029446 int32_t yg = (special==spw_floater)?8:0;
1516 19029446 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1517
2/2
✓ Branch 0 taken 1960677 times.
✓ Branch 1 taken 17068769 times.
19029446 switch(dir)
1518 {
1519 case l_down:
1520 case r_down:
1521 case down:
1522 case 11: //r_down
1523 case 12: //down
1524 case 13: //l_down
1525 {
1526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
1960677 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1527 {
1528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1960677 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1529 {
1530 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1531 dy += zc_max(hit_height-16,0);
1532 }
1533 1960677 }
1534 1960677 break;
1535 }
1536 }
1537
2/2
✓ Branch 0 taken 1972909 times.
✓ Branch 1 taken 17056537 times.
19029446 switch(dir)
1538 {
1539 case r_up:
1540 case r_down:
1541 case right:
1542 case 9: //r_up
1543 case 10: //right
1544 case 11: //r_down
1545 {
1546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
1972909 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1547 {
1548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1972909 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1549 {
1550 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1551 dx += zc_max(hit_width-16,0);
1552 }
1553 1972909 }
1554 1972909 break;
1555 }
1556 }
1557 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1558
1559
10/10
✓ Branch 0 taken 13730315 times.
✓ Branch 1 taken 5299131 times.
✓ Branch 2 taken 4431976 times.
✓ Branch 3 taken 867155 times.
✓ Branch 4 taken 5287042 times.
✓ Branch 5 taken 12089 times.
✓ Branch 6 taken 5274023 times.
✓ Branch 7 taken 13019 times.
✓ Branch 8 taken 13757809 times.
✓ Branch 9 taken 19031832 times.
19029446 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1560 27513232 return true;
1561
1562 19031832 bool isInDungeon = isdungeon();
1563
4/4
✓ Branch 0 taken 1581593 times.
✓ Branch 1 taken 17450239 times.
✓ Branch 2 taken 1123 times.
✓ Branch 3 taken 1580470 times.
19031832 if(isInDungeon || special==spw_wizzrobe)
1564 {
1565
8/8
✓ Branch 0 taken 3601717 times.
✓ Branch 1 taken 13849645 times.
✓ Branch 2 taken 3471583 times.
✓ Branch 3 taken 130134 times.
✓ Branch 4 taken 3560656 times.
✓ Branch 5 taken 10419123 times.
✓ Branch 6 taken 3560642 times.
✓ Branch 7 taken 14 times.
17451362 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1566 7032225 return true;
1567
1568
8/8
✓ Branch 0 taken 3512677 times.
✓ Branch 1 taken 6906460 times.
✓ Branch 2 taken 3413625 times.
✓ Branch 3 taken 99052 times.
✓ Branch 4 taken 3480646 times.
✓ Branch 5 taken 3524866 times.
✓ Branch 6 taken 3480643 times.
✓ Branch 7 taken 3 times.
10419137 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1569
2/2
✓ Branch 0 taken 66979 times.
✓ Branch 1 taken 39 times.
6894268 if(special!=spw_door) // walk in door way
1570 66979 return true;
1571 3524908 }
1572
1573
6/6
✓ Branch 0 taken 2212798 times.
✓ Branch 1 taken 2892580 times.
✓ Branch 2 taken 427580 times.
✓ Branch 3 taken 1785218 times.
✓ Branch 4 taken 34289 times.
✓ Branch 5 taken 393291 times.
5105378 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
1574 {
1575
3/4
✓ Branch 0 taken 2178502 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2178502 times.
4357011 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1576
2/4
✓ Branch 0 taken 2178502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178502 times.
✗ Branch 3 not taken.
2178502 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1577 7 return true;
1578 2178502 }
1579
1580
4/4
✓ Branch 0 taken 4093655 times.
✓ Branch 1 taken 1008118 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 3553 times.
5105371 switch(special)
1581 {
1582 case spw_clipbottomright:
1583
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
1584 45 break;
1585 case spw_clipright:
1586 3553 break; //if(input_x>=208) return true; break;
1587
1588 case spw_wizzrobe: // fall through
1589 case spw_floater: // Special case for fliers and wizzrobes - hack!
1590 {
1591
2/2
✓ Branch 0 taken 1101316 times.
✓ Branch 1 taken 2992339 times.
4093655 if(isInDungeon)
1592 {
1593
3/4
✓ Branch 0 taken 2992328 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2992328 times.
2992339 if(dy < 32-yg || dy >= 144) return true;
1594
3/4
✓ Branch 0 taken 2991477 times.
✓ Branch 1 taken 851 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2991477 times.
2992328 if(dx < 32 || dx >= 224) return true;
1595 2991477 }
1596 4092793 return false;
1597 }
1598 }
1599
1600 1011716 dx&=(special==spw_halfstep)?(~7):(~15);
1601
2/2
✓ Branch 0 taken 224029 times.
✓ Branch 1 taken 787687 times.
1011716 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1602
1603
2/2
✓ Branch 0 taken 117322 times.
✓ Branch 1 taken 894394 times.
1011716 if(special==spw_water)
1604
2/2
✓ Branch 0 taken 8245 times.
✓ Branch 1 taken 109077 times.
117322 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1605
1606
2/2
✓ Branch 0 taken 892220 times.
✓ Branch 1 taken 2174 times.
894394 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1607 {
1608
4/4
✓ Branch 0 taken 666298 times.
✓ Branch 1 taken 225922 times.
✓ Branch 2 taken 660380 times.
✓ Branch 3 taken 5918 times.
1552600 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
2/2
✓ Branch 0 taken 2852 times.
✓ Branch 1 taken 657528 times.
660380 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1610 }
1611 else
1612 {
1613
4/4
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 555 times.
✓ Branch 2 taken 1607 times.
✓ Branch 3 taken 12 times.
3781 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1614
3/4
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1599 times.
✗ Branch 3 not taken.
1607 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1615
3/4
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1565 times.
✗ Branch 3 not taken.
1599 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1565 times.
1565 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1617 }
1618 5314018 }
1619
1620 383430 bool enemy::isOnSideviewPlatform()
1621 {
1622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1624
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1626
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1627 {
1628
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1629
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1631 47357 }
1632 168001 return false;
1633 383430 }
1634
1635 // Stops playing the given sound only if there are no enemies left to play it
1636 451658 void enemy::stop_bgsfx(int32_t index)
1637 {
1638
2/2
✓ Branch 0 taken 441954 times.
✓ Branch 1 taken 9704 times.
451658 if(bgsfx<=0)
1639 441954 return;
1640
1641 // Look for other enemies with the same bgsfx
1642
2/2
✓ Branch 0 taken 39307 times.
✓ Branch 1 taken 5718 times.
45025 for(int32_t i=0; i<guys.Count(); i++)
1643 {
1644
4/4
✓ Branch 0 taken 32357 times.
✓ Branch 1 taken 6950 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 28371 times.
39307 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1645 3986 return;
1646 35321 }
1647
1648 5718 stop_sfx(bgsfx);
1649 451658 }
1650
1651
1652 // to allow for different sfx on defeating enemy
1653 21658 void enemy::death_sfx()
1654 {
1655
2/2
✓ Branch 0 taken 21634 times.
✓ Branch 1 taken 24 times.
21658 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1656 21658 }
1657
1658 void enemy::move(zfix dx,zfix dy)
1659 {
1660 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1661 {
1662 switch(family)
1663 {
1664 case eeFIRE:
1665 case eeOTHER:
1666 return;
1667 default: break;
1668 }
1669 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1670 }
1671 */
1672 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
1673 {
1674 x+=dx;
1675 y+=dy;
1676 }
1677 }
1678
1679 10385398 void enemy::move(zfix s)
1680 {
1681 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1682 {
1683 switch(family)
1684 {
1685 case eeFIRE:
1686 case eeOTHER:
1687 return;
1688 default: break;
1689 }
1690 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1691 }*/
1692
9/10
✓ Branch 0 taken 10385359 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 10305597 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
10385398 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
1693 {
1694 10384504 sprite::move(s);
1695 10384504 }
1696 10385398 }
1697
1698 24760 void enemy::leave_item()
1699 {
1700 24760 int32_t drop_item = select_dropitem(item_set, x, y);
1701 24760 int32_t thedropset = item_set;
1702
1703 24760 std::vector<int32_t> &ev = FFCore.eventData;
1704 24760 ev.clear();
1705 24760 ev.push_back(getUID());
1706 24760 ev.push_back(drop_item*10000);
1707 24760 ev.push_back(thedropset*10000);
1708
1709 24760 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1710 24760 drop_item = vbound(ev[1] / 10000,-2,255);
1711 24760 thedropset = ev[2] / 10000;
1712 24760 ev.clear();
1713
1/2
✓ Branch 0 taken 24760 times.
✗ Branch 1 not taken.
24760 if(drop_item == -2)
1714 {
1715 drop_item = select_dropitem(thedropset,x,y);
1716 }
1717
1718
6/6
✓ Branch 0 taken 9759 times.
✓ Branch 1 taken 15001 times.
✓ Branch 2 taken 563 times.
✓ Branch 3 taken 9196 times.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 414 times.
24760 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1719 {
1720 item* itm;
1721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9610 times.
9610 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1722 {
1723 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1724 }
1725 else
1726 {
1727
8/14
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 8174 times.
✓ Branch 2 taken 1436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1436 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1436 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1436 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1436 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1436 times.
✗ Branch 13 not taken.
9610 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1728
4/8
✓ Branch 0 taken 8174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8174 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8174 times.
✗ Branch 7 not taken.
8174 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1729 }
1730 9610 itm->from_dropset = thedropset;
1731 9610 items.add(itm);
1732
1733 9610 ev.push_back(getUID());
1734 9610 ev.push_back(itm->getUID());
1735
1736 9610 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1737 9610 ev.clear();
1738 9610 }
1739 24760 }
1740
1741 // auomatically kill off enemy (for rooms with ringleaders)
1742 344 void enemy::kickbucket()
1743 {
1744
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 32 times.
344 if(!superman)
1745 312 hp=-1000; // don't call death_sfx()
1746 344 }
1747
1748 3278 bool enemy::isSubmerged() const
1749 {
1750 3278 return submerged;
1751 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1752 }
1753
1754 17408 void enemy::FireBreath(bool seekhero)
1755 {
1756
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(wpn==wNone)
1757 return;
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17408 times.
17408 if(wpn==ewFireTrail)
1760 {
1761 dmisc1 = e1tEACHTILE;
1762 FireWeapon();
1763 return;
1764 }
1765
1766 17408 float fire_angle=0.0;
1767 17408 int32_t wx=0, wy=0, wdir=dir;
1768
1769
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 if(!seekhero)
1770 {
1771
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
1772 {
1773 case down:
1774 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1775 3038 wx=x;
1776 3038 wy=y+8;
1777 3038 break;
1778
1779 case -1:
1780 case up:
1781 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1782 3271 wx=x;
1783 3271 wy=y-8;
1784 3271 break;
1785
1786 case left:
1787 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1788 5264 wx=x-8;
1789 5264 wy=y;
1790 5264 break;
1791
1792 case right:
1793 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1794 4131 wx=x+8;
1795 4131 wy=y;
1796 4131 break;
1797 }
1798
1799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
1800 {
1801
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
1806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
1807
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
1808
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
1809 15704 }
1810 15704 }
1811 else
1812 {
1813 1704 wx = x;
1814 1704 wy = y;
1815 }
1816
1817
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1818 17408 sfx(wpnsfx(wpn),pan(int32_t(x)));
1819
1820 17408 int32_t i=Ewpns.Count()-1;
1821 17408 weapon *ew = (weapon*)(Ewpns.spr(i));
1822 17408 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1823
1824
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1704 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17408 if(!seekhero && (zc_oldrand()&4))
1825 {
1826 7874 ew->angular=true;
1827 7874 ew->angle=fire_angle;
1828 7874 }
1829
1830
4/4
✓ Branch 0 taken 17351 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 17034 times.
17408 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1831 {
1832 17034 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17034 times.
17034 if ( ew->do_animation ) ew->tile+=ew->aframe;
1834 17034 }
1835
1836
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 543348 times.
560756 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1837 {
1838 543348 Ewpns.swap(j,j-1);
1839 543348 }
1840 17408 }
1841
1842 28308 void enemy::FireWeapon()
1843 {
1844 /*
1845 * Type:
1846 * 0x01: Boss fireball
1847 * 0x02: Seeks Hero
1848 * 0x04: Fast projectile
1849 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1850 */
1851
1852
2/2
✓ Branch 0 taken 28298 times.
✓ Branch 1 taken 10 times.
28308 if (wpn < 1) return;
1853
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
28298 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1854 return;
1855
1856
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28298 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1857 dmisc1 = e1tEACHTILE;
1858
1859 28298 int32_t xoff = 0;
1860 28298 int32_t yoff = 0;
1861
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1862 {
1863 xoff += (hit_width/2)-8;
1864 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1865 }
1866
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1867 {
1868 yoff += (hit_height/2)-8;
1869 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1870 }
1871
1872
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 26887 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28298 switch(dmisc1)
1873 {
1874 case e1t5SHOTS: //BS-Aquamentus
1875 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1879
1880 [[fallthrough]];
1881 case e1t3SHOTSFAST:
1882 case e1t3SHOTS: //Aquamentus
1883
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1884 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1885
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1886 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887
1888 [[fallthrough]];
1889 default:
1890
11/20
✓ Branch 0 taken 27300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 27300 times.
✓ Branch 12 taken 27300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11345 times.
✓ Branch 15 taken 15955 times.
✓ Branch 16 taken 27300 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27300 times.
✗ Branch 19 not taken.
27300 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1891 27300 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1892 27300 sfx(wpnsfx(wpn),pan(int32_t(x)));
1893 27300 break;
1894
1895 case e1tSLANT:
1896 {
1897 409 int32_t slant = 0;
1898
1899
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1900 236 slant = left;
1901
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1902 112 slant = right;
1903
1904
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1905 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1906 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
1907 319 break;
1908 }
1909
1910 case e1t8SHOTS: //Fire Wizzrobe
1911 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1912 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1913 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1914 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1916 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1917 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1918 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1919 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1920 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1921 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1922 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1923
1924 [[fallthrough]];
1925 case e1t4SHOTS: //Stalfos 3
1926
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1927 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1928 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1929
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1930 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1931 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1932
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1933 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1934 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1935
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1936 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1937 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1938 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
1939 589 break;
1940
1941 case e1tSUMMON: // Bat Wizzrobe
1942 {
1943 //al_trace("Summon Bats\n");
1944 //zprint2("Summon Bats\n");
1945 if(dmisc4==0) break; // Summon 0
1946
1947 int32_t bc=0;
1948
1949 for(int32_t gc=0; gc<guys.Count(); gc++)
1950 {
1951 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1952 {
1953 ++bc;
1954 }
1955 }
1956
1957 if(bc<=40) // Not too many enemies
1958 {
1959 int32_t kids = guys.Count();
1960 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1961
1962 for(int32_t i=0; i<bats; i++)
1963 {
1964 //zprint2("summon\n");
1965 //al_trace("summon\n");
1966 if(addchild(x,y,dmisc3,-10, this->script_UID))
1967 {
1968 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1969 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
1970 //zprint2("Summoner Script UID: %d\n",this->script_UID);
1971
1972 }
1973 }
1974
1975 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1976 }
1977
1978 break;
1979 }
1980
1981 case e1tSUMMONLAYER: // Summoner
1982 {
1983 if(count_layer_enemies()==0)
1984 {
1985 break;
1986 }
1987
1988 int32_t kids = guys.Count();
1989
1990 if(kids<40)
1991 {
1992 int32_t newguys=(zc_oldrand()%3)+1;
1993 bool summoned=false;
1994
1995 for(int32_t i=0; i<newguys; i++)
1996 {
1997 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
1998 int32_t x2=0;
1999 int32_t y2=0;
2000
2001 for(int32_t k=0; k<20; ++k)
2002 {
2003 x2=16*((zc_oldrand()%12)+2);
2004 y2=16*((zc_oldrand()%7)+2);
2005
2006 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2007 {
2008 //zprint2("summon\n");
2009 //al_trace("summon\n");
2010 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2011 {
2012 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2013 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
2014 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
2015 {
2016 ((enemy*)guys.spr(kids+i))->fakez = 64;
2017 ((enemy*)guys.spr(kids+i))->z = 0;
2018 }
2019 }
2020
2021 summoned=true;
2022 break;
2023 }
2024 }
2025 }
2026
2027 if(summoned)
2028 {
2029 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2030 }
2031 }
2032
2033 break;
2034 }
2035 }
2036 28218 }
2037
2038
2039 // Hit the shield(s)?
2040 // Apparently, this function is only used for hookshots...
2041 398 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2042 {
2043
4/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
398 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2044 106 return false;
2045
2046 292 bool ret = false;
2047
2048 // TODO: There must be some bitwise operations that can simplify this...
2049
9/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
292 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
2050
9/12
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
155 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
2051
2052
11/14
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 185 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 95 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 101 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 13 not taken.
300 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
2053
10/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 141 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 141 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 141 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
185 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
2054
2055 300 return ret;
2056 406 }
2057
2058
2059 //! Weapon Editor for 2.6
2060 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2061
2062
2063 //converts a wqeapon ID to its defence index.
2064 73090 int32_t weaponToDefence(int32_t wid)
2065 {
2066
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32485 times.
✓ Branch 3 taken 6764 times.
✓ Branch 4 taken 18964 times.
✓ Branch 5 taken 702 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1549 times.
✓ Branch 10 taken 7171 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 1166 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 322 times.
✓ Branch 18 taken 920 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 866 times.
✓ Branch 21 taken 406 times.
✓ Branch 22 taken 118 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 325 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 993 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
73090 switch(wid)
2067 {
2068 case wNone: return -1;
2069 32485 case wSword: return edefSWORD;
2070 6764 case wBeam: return edefBEAM;
2071 18964 case wBrang: return edefBRANG;
2072 702 case wBomb: return edefBOMB;
2073 28 case wSBomb: return edefSBOMB;
2074 48 case wLitBomb: return edefBOMB;
2075 case wLitSBomb: return edefSBOMB;
2076 1549 case wArrow: return edefARROW;
2077 7171 case wFire: return edefFIRE;
2078 case wWhistle:
2079 {
2080 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
2081 return edefWhistle;
2082 }
2083 case wBait: return edefBAIT;
2084 163 case wWand: return edefWAND;
2085 1166 case wMagic: return edefMAGIC;
2086 case wCatching: return -1;
2087 case wWind: return edefWIND;
2088 322 case wRefMagic: return edefREFMAGIC;
2089 920 case wRefFireball: return edefREFBALL;
2090 case wRefRock: return edefREFROCK;
2091 866 case wHammer: return edefHAMMER;
2092 406 case wHookshot: return edefHOOKSHOT;
2093 118 case wHSHandle: return edefHOOKSHOT;
2094 case wHSChain: return edefHOOKSHOT;
2095 case wSSparkle: return edefSPARKLE;
2096 325 case wFSparkle: return edefSPARKLE;
2097 case wSmack: return -1; // is this the candle object?
2098 case wPhantom: return -1; //engine created visual effects.
2099 case wCByrna: return edefBYRNA;
2100 11 case wRefBeam: return edefREFBEAM;
2101 case wStomp: return edefSTOMP;
2102 case wScript1: return edefSCRIPT01;
2103 case wScript2: return edefSCRIPT02;
2104 12 case wScript3: return edefSCRIPT03;
2105 77 case wScript4: return edefSCRIPT04;
2106 case wScript5: return edefSCRIPT05;
2107 case wScript6: return edefSCRIPT06;
2108 case wScript7: return edefSCRIPT07;
2109 case wScript8: return edefSCRIPT08;
2110 case wScript9: return edefSCRIPT09;
2111 993 case wScript10: return edefSCRIPT10;
2112 case wIce: return edefICE;
2113 case wSound: return edefSONIC;
2114 case wThrown: return edefTHROWN;
2115 //case wPot: return edefPOT;
2116 // case wLitZap: return edefELECTRIC;
2117 // case wZ3Sword: return edefZ3SWORD;
2118 // case wLASWord: return edefLASWORD;
2119 // case wSpinAttk: return edefSPINATTK;
2120 // case wShield: return edefSHIELD;
2121 // case wTrowel: return edefTROWEL;
2122
2123 default: return -1;
2124 }
2125 73090 }
2126
2127 73090 int32_t getDefType(weapon *w)
2128 {
2129 73090 int32_t id = getWeaponID(w);
2130 73090 int32_t edef = weaponToDefence(id);
2131
2/2
✓ Branch 0 taken 72566 times.
✓ Branch 1 taken 524 times.
73090 if(edef == edefHOOKSHOT)
2132 {
2133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if(w->family_class == itype_switchhook)
2134 return edefSwitchHook;
2135 524 }
2136 73090 return edef;
2137 73090 }
2138
2139 126810 int32_t getWeaponID(weapon *w)
2140 {
2141 126810 int32_t usewpn = w->useweapon;
2142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126810 times.
126810 return (usewpn > 0) ? usewpn : w->id;
2143 }
2144
2145 73090 int32_t enemy::resolveEnemyDefence(weapon *w)
2146 {
2147 //sword edef is 9, but we're reading it at 0
2148 //,
2149 73090 int32_t weapondef = 0;
2150 73090 int32_t wdeftype = getDefType(w);
2151 73090 int32_t usedef = w->usedefence;
2152
2153
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
73090 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2154 {
2155 weapondef = usedef*-1;
2156 }
2157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
73090 else if(unsigned(wdeftype) < edefLAST255)
2158 {
2159 73090 weapondef = wdeftype;
2160 73090 }
2161 73090 return weapondef;
2162 }
2163
2164 79108 byte get_def_ignrflag(int32_t edef)
2165 {
2166
3/3
✓ Branch 0 taken 66047 times.
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 10732 times.
79108 switch(edef)
2167 {
2168 case edIGNORE:
2169 case edIGNOREL1:
2170 case edSTUNORIGNORE:
2171 10732 return WPNUNB_IGNR;
2172 case edSTUNORCHINK:
2173 case edCHINK:
2174 case edCHINKL1:
2175 case edCHINKL2:
2176 case edCHINKL4:
2177 case edCHINKL6:
2178 case edCHINKL8:
2179 case edCHINKL10:
2180 case edLEVELCHINK2:
2181 case edLEVELCHINK3:
2182 case edLEVELCHINK4:
2183 case edLEVELCHINK5:
2184 2329 return WPNUNB_BLOCK;
2185 }
2186 66047 return 0;
2187 79108 }
2188
2189 79108 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2190 {
2191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79108 times.
79108 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2192 switch(edef)
2193 {
2194 case edIGNORE:
2195 case edIGNOREL1:
2196 case edCHINK:
2197 case edCHINKL1:
2198 case edCHINKL2:
2199 case edCHINKL4:
2200 case edCHINKL6:
2201 case edCHINKL8:
2202 case edCHINKL10:
2203 case edLEVELCHINK2:
2204 case edLEVELCHINK3:
2205 case edLEVELCHINK4:
2206 case edLEVELCHINK5:
2207 return edNORMAL;
2208 case edSTUNORIGNORE:
2209 case edSTUNORCHINK:
2210 return edSTUNONLY;
2211 }
2212 return edef;
2213 79108 }
2214
2215 // Do we do damage?
2216 // 0: takehit returns 0
2217 // 1: takehit returns 1
2218 // -1: do damage
2219 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2220 72097 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2221 {
2222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(switch_hooked) return 0;
2223 72097 int32_t tempx = x;
2224 72097 int32_t tempy = y;
2225 72097 int32_t the_defence = 0;
2226
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2227 {
2228 the_defence = edef*-1; //A specific defence type.
2229 }
2230 72097 else the_defence = defense[edef];
2231
2232 72097 the_defence = conv_edef_unblockable(the_defence, unblockable);
2233
2234
3/4
✓ Branch 0 taken 4350 times.
✓ Branch 1 taken 67747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4350 times.
72097 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2235 {
2236
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4343 times.
✓ Branch 2 taken 7 times.
4350 switch(the_defence)
2237 {
2238 case edIGNORE:
2239 7 return 0;
2240 case edIGNOREL1:
2241 case edSTUNORIGNORE:
2242 if(*power <= 0)
2243 return 0;
2244 }
2245 4343 sfx(WAV_CHINK,pan(int32_t(x)));
2246 4343 return 1;
2247 }
2248
2249 67747 int32_t new_id = id;
2250 67747 int32_t effect_type = dmisc15;
2251 67747 int32_t delay_timer = 90;
2252 67747 enemy *gleeok = NULL;
2253 67747 enemy *ptra = NULL;
2254 67747 int32_t c = 0;
2255
2256
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 902 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 199 times.
✓ Branch 13 taken 9312 times.
✓ Branch 14 taken 173 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1789 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 53312 times.
67747 switch(the_defence)
2257 {
2258 case edREPLACE:
2259 {
2260 sclk = 0;
2261 if ( dmisc16 > 0 ) new_id = dmisc16;
2262 else new_id = id+1;
2263 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2264 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2265 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2266
2267 //Z_scripterrlog("new id is %d\n", new_id);
2268 switch(guysbuf[new_id&0xFFF].family)
2269 {
2270 //Fixme: possible enemy memory leak. (minor)
2271 case eeWALK:
2272 {
2273 enemy *e = new eStalfos(x,y,new_id,clk);
2274 guys.add(e);
2275 }
2276 break;
2277
2278 case eeLEV:
2279 {
2280 enemy *e = new eLeever(x,y,new_id,clk);
2281 guys.add(e);
2282 }
2283 break;
2284
2285 case eeTEK:
2286 {
2287 enemy *e = new eTektite(x,y,new_id,clk);
2288 guys.add(e);
2289 }
2290 break;
2291
2292 case eePEAHAT:
2293 {
2294 enemy *e = new ePeahat(x,y,new_id,clk);
2295 guys.add(e);
2296 }
2297 break;
2298
2299 case eeZORA:
2300 {
2301 enemy *e = new eZora(x,y,new_id,clk);
2302 guys.add(e);
2303 }
2304 break;
2305
2306 case eeGHINI:
2307 {
2308 enemy *e = new eGhini(x,y,new_id,clk);
2309 guys.add(e);
2310 }
2311 break;
2312
2313 case eeKEESE:
2314 {
2315 enemy *e = new eKeese(x,y,new_id,clk);
2316 guys.add(e);
2317 }
2318 break;
2319
2320 case eeWIZZ:
2321 {
2322 enemy *e = new eWizzrobe(x,y,new_id,clk);
2323 guys.add(e);
2324 }
2325 break;
2326
2327 case eePROJECTILE:
2328 {
2329 enemy *e = new eProjectile(x,y,new_id,clk);
2330 guys.add(e);
2331 }
2332 break;
2333
2334 case eeWALLM:
2335 {
2336 enemy *e = new eWallM(x,y,new_id,clk);
2337 guys.add(e);
2338 }
2339 break;
2340
2341 case eeAQUA:
2342 {
2343 enemy *e = new eAquamentus(x,y,new_id,clk);
2344 guys.add(e);
2345 e->x = x;
2346 e->y = y;
2347 }
2348 break;
2349
2350 case eeMOLD:
2351 {
2352 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
2353 guys.add(e);
2354 e->x = x;
2355 e->y = y;
2356 }
2357 break;
2358
2359 case eeMANHAN:
2360 {
2361 enemy *e = new eManhandla(x,y,new_id,clk);
2362 guys.add(e);
2363 e->x = x;
2364 e->y = y;
2365 }
2366 break;
2367
2368 case eeGLEEOK:
2369 {
2370 *power = 0;
2371 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
2372 guys.add(gleeok);
2373 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2374 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2375 new_id &= 0xFFF;
2376 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2377 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2378 for(int32_t i=0; i<head_cnt; i++)
2379 {
2380 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2381 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2382 {
2383 al_trace("Gleeok head %d could not be created!\n",i+1);
2384
2385 for(int32_t j=0; j<i+1; j++)
2386 {
2387 guys.del(guys.Count()-1);
2388 }
2389
2390 break;
2391 }
2392 else
2393 {
2394 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2395 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2396 }
2397
2398 c-=guysbuf[new_id].misc4;
2399 //gleeok->x = x;
2400 //gleeok->y = y;
2401 //gleeok = e;
2402 }
2403 return 1;
2404 }
2405
2406 case eeGHOMA:
2407 {
2408 enemy *e = new eGohma(x,y,new_id,clk);
2409 guys.add(e);
2410 e->x = x;
2411 e->y = y;
2412 }
2413 break;
2414
2415 case eeLANM:
2416 {
2417 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
2418 guys.add(e);
2419 e->x = x;
2420 e->y = y;
2421 }
2422 break;
2423
2424 case eeGANON:
2425 {
2426 enemy *e = new eGanon(x,y,new_id,clk);
2427 guys.add(e);
2428 e->x = x;
2429 e->y = y;
2430 }
2431 break;
2432
2433 case eeFAIRY:
2434 {
2435 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2436 guys.add(e);
2437 e->x = x;
2438 e->y = y;
2439 }
2440 break;
2441
2442 case eeFIRE:
2443 {
2444 enemy *e = new eFire(x,y,new_id,clk);
2445 guys.add(e);
2446 e->x = x;
2447 e->y = y;
2448 }
2449 break;
2450
2451 case eeOTHER:
2452 {
2453 enemy *e = new eOther(x,y,new_id,clk);
2454 guys.add(e);
2455 e->x = x;
2456 e->y = y;
2457 }
2458 break;
2459
2460 case eeSPINTILE:
2461 {
2462 enemy *e = new eSpinTile(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 // and these enemies use the misc10/misc2 value
2470 case eeROCK:
2471 {
2472 switch(guysbuf[new_id&0xFFF].misc10)
2473 {
2474 case 1:
2475 {
2476 enemy *e = new eBoulder(x,y,new_id,clk);
2477 guys.add(e);
2478 e->x = x;
2479 e->y = y;
2480 }
2481 break;
2482
2483 case 0:
2484 default:
2485 {
2486 enemy *e = new eRock(x,y,new_id,clk);
2487 guys.add(e);
2488 e->x = x;
2489 e->y = y;
2490 }
2491 break;
2492 }
2493
2494 break;
2495 }
2496
2497 case eeTRAP:
2498 {
2499 switch(guysbuf[new_id&0xFFF].misc2)
2500 {
2501 case 1:
2502 {
2503 enemy *e = new eTrap2(x,y,new_id,clk);
2504 guys.add(e);
2505 e->x = x;
2506 e->y = y;
2507 }
2508 break;
2509
2510 case 0:
2511 default:
2512 {
2513 enemy *e = new eTrap(x,y,new_id,clk);
2514 guys.add(e);
2515 e->x = x;
2516 e->y = y;
2517 }
2518 break;
2519 }
2520
2521 break;
2522 }
2523
2524 case eeDONGO:
2525 {
2526 switch(guysbuf[new_id&0xFFF].misc10)
2527 {
2528 case 1:
2529 {
2530 enemy *e = new eDodongo2(x,y,new_id,clk);
2531 guys.add(e);
2532 e->x = x;
2533 e->y = y;
2534 }
2535 break;
2536
2537 case 0:
2538 default:
2539 {
2540 enemy *e = new eDodongo(x,y,new_id,clk);
2541 guys.add(e);
2542 e->x = x;
2543 e->y = y;
2544 }
2545 break;
2546 }
2547
2548 break;
2549 }
2550
2551 case eeDIG:
2552 {
2553 switch(guysbuf[new_id&0xFFF].misc10)
2554 {
2555 case 1:
2556 {
2557 enemy *e = new eLilDig(x,y,new_id,clk);
2558 guys.add(e);
2559 e->x = x;
2560 e->y = y;
2561 }
2562 break;
2563
2564 case 0:
2565 default:
2566 {
2567 enemy *e = new eBigDig(x,y,new_id,clk);
2568 guys.add(e);
2569 e->x = x;
2570 e->y = y;
2571 }
2572 break;
2573 }
2574
2575 break;
2576 }
2577
2578 case eePATRA:
2579 {
2580 switch(guysbuf[new_id&0xFFF].misc10)
2581 {
2582 case 1:
2583 {
2584 if (get_qr(qr_HARDCODED_BS_PATRA))
2585 {
2586 enemy *e = new ePatraBS(x,y,new_id,clk);
2587 guys.add(e);
2588 e->x = x;
2589 e->y = y;
2590 break;
2591 }
2592 }
2593 [[fallthrough]];
2594 case 0:
2595 default:
2596 {
2597 enemy *e = new ePatra(x,y,new_id,clk);
2598 guys.add(e);
2599 e->x = x;
2600 e->y = y;
2601 }
2602 break;
2603 }
2604
2605 break;
2606 }
2607
2608 case eeGUY:
2609 {
2610 switch(guysbuf[new_id&0xFFF].misc10)
2611 {
2612 case 1:
2613 {
2614 enemy *e = new eTrigger(x,y,new_id,clk);
2615 guys.add(e);
2616 }
2617 break;
2618
2619 case 0:
2620 default:
2621 {
2622 enemy *e = new eNPC(x,y,new_id,clk);
2623 guys.add(e);
2624 }
2625 break;
2626 }
2627
2628 break;
2629 }
2630
2631 case eeSCRIPT01:
2632 case eeSCRIPT02:
2633 case eeSCRIPT03:
2634 case eeSCRIPT04:
2635 case eeSCRIPT05:
2636 case eeSCRIPT06:
2637 case eeSCRIPT07:
2638 case eeSCRIPT08:
2639 case eeSCRIPT09:
2640 case eeSCRIPT10:
2641 case eeSCRIPT11:
2642 case eeSCRIPT12:
2643 case eeSCRIPT13:
2644 case eeSCRIPT14:
2645 case eeSCRIPT15:
2646 case eeSCRIPT16:
2647 case eeSCRIPT17:
2648 case eeSCRIPT18:
2649 case eeSCRIPT19:
2650 case eeSCRIPT20:
2651 {
2652 enemy *e = new eScript(x,y,new_id,clk);
2653 guys.add(e);
2654 e->x = x;
2655 e->y = y;
2656 break;
2657 }
2658
2659
2660 case eeFFRIENDLY01:
2661 case eeFFRIENDLY02:
2662 case eeFFRIENDLY03:
2663 case eeFFRIENDLY04:
2664 case eeFFRIENDLY05:
2665 case eeFFRIENDLY06:
2666 case eeFFRIENDLY07:
2667 case eeFFRIENDLY08:
2668 case eeFFRIENDLY09:
2669 case eeFFRIENDLY10:
2670 {
2671 enemy *e = new eFriendly(x,y,new_id,clk);
2672 guys.add(e);
2673 e->x = x;
2674 e->y = y;
2675 break;
2676 }
2677
2678
2679 default: break;
2680 }
2681
2682 // add segments of segmented enemies
2683 int32_t c=0;
2684
2685 switch(guysbuf[new_id&0xFFF].family)
2686 {
2687 case eeMOLD:
2688 {
2689 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2690 new_id &= 0xFFF;
2691
2692 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
2693 {
2694 //christ this is messy -DD
2695 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2696
2697 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2698 {
2699 al_trace("Moldorm segment %d could not be created!\n",i+1);
2700
2701 for(int32_t j=0; j<i+1; j++)
2702 guys.del(guys.Count()-1);
2703
2704 return 0;
2705 }
2706
2707 if(i>0)
2708 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2709
2710
2711 }
2712
2713 break;
2714 }
2715
2716 case eeLANM:
2717 {
2718 new_id &= 0xFFF;
2719 int32_t shft = guysbuf[new_id].misc2;
2720 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2721 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2722
2723 if(!guys.add(e))
2724 {
2725 al_trace("Lanmola segment 1 could not be created!\n");
2726 guys.del(guys.Count()-1);
2727 return 0;
2728 }
2729 e->x = x;
2730 e->y = y;
2731
2732
2733
2734 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
2735 {
2736 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2737 if(!guys.add(e2))
2738 {
2739 al_trace("Lanmola segment %d could not be created!\n",i+1);
2740
2741 for(int32_t j=0; j<i+1; j++)
2742 guys.del(guys.Count()-1);
2743
2744 return 0;
2745 }
2746 e2->x = x;
2747 e2->y = y;
2748
2749 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2750
2751 }
2752 }
2753 break;
2754
2755 case eeMANHAN:
2756 new_id &= 0xFFF;
2757
2758 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
2759 {
2760 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2761 {
2762 al_trace("Manhandla head %d could not be created!\n",i+1);
2763
2764 for(int32_t j=0; j<i+1; j++)
2765 {
2766 guys.del(guys.Count()-1);
2767 }
2768
2769 return 0;
2770 }
2771
2772
2773 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
2774 }
2775
2776 break;
2777
2778 case eeGLEEOK:
2779 {
2780 /*
2781 new_id &= 0xFFF;
2782 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2783 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2784 for(int32_t i=0; i<head_cnt; i++)
2785 {
2786 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2787 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2788 {
2789 al_trace("Gleeok head %d could not be created!\n",i+1);
2790
2791 for(int32_t j=0; j<i+1; j++)
2792 {
2793 guys.del(guys.Count()-1);
2794 }
2795
2796 break;
2797 }
2798
2799 c-=guysbuf[new_id].misc4;
2800 */
2801
2802 // }
2803 }
2804 break;
2805
2806
2807 case eePATRA:
2808 {
2809 new_id &= 0xFFF;
2810 int32_t outeyes = 0;
2811 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2812
2813 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
2814 {
2815 if(!((guysbuf[new_id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2816 {
2817 al_trace("Patra outer eye %d could not be created!\n",i+1);
2818
2819 for(int32_t j=0; j<i+1; j++)
2820 guys.del(guys.Count()-1);
2821
2822 return 0;
2823 }
2824 else
2825 outeyes++;
2826
2827
2828 }
2829
2830 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
2831 {
2832 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2833 {
2834 al_trace("Patra inner eye %d could not be created!\n",i+1);
2835
2836 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2837 guys.del(guys.Count()-1);
2838
2839 return 0;
2840 }
2841
2842
2843 }
2844 delete ptra;
2845 break;
2846 }
2847 }
2848
2849
2850
2851 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2852 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2853 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2854 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2855 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2856 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2857 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2858 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
2859 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2860 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2861 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2862 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2863 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2864 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2865
2866
2867 item_set = 0; //Do not make a drop.
2868
2869 switch(effect_type)
2870 {
2871 case -7:
2872 {
2873 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2874 Lwpns.add(w);
2875 break;
2876 }
2877 case -6:
2878 {
2879 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2880 Lwpns.add(w);
2881 break;
2882 }
2883 case -5:
2884 {
2885 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2886 Lwpns.add(w);
2887 break;
2888 }
2889 case -4:
2890 {
2891 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2892 Lwpns.add(w);
2893 break;
2894 }
2895 case -3: explode(1); break;
2896 case -2: explode(2); break;
2897 case -1: explode(0); break;
2898 case 0: break;
2899
2900 default:
2901 {
2902 //Dummy weapon function
2903 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2904 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2905 Lwpns.add(w);
2906 break;
2907 }
2908 }
2909
2910
2911 yofs = -32768;
2912 switch(guysbuf[new_id&0xFFF].family)
2913 {
2914 case eeGLEEOK:
2915 {
2916 Z_scripterrlog("Replacing a gleeok.\n");
2917 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2918 hp = -999;
2919 tempenemy->hp = -999;
2920 break;
2921
2922 }
2923 default:
2924 hp = -1000; break;
2925 }
2926 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2927 return 1;
2928
2929 }
2930 case edSPLIT:
2931 {
2932 //int32_t ex = x; int32_t ey = y;
2933 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2934 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2935 /*
2936 if ( txsx > 1 )
2937 {
2938 ex += ( txsz-1 ) * 8; //from its middle
2939 }
2940 if ( tysx > 1 )
2941 {
2942 ey += ( tysz-1 ) * 8; //from its middle
2943 }
2944 */
2945 for ( int32_t q = 0; q < dmisc4; q++ )
2946 {
2947
2948 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
2949 addenemy(
2950 //ex,ey,
2951 x,y,
2952 dmisc3+0x1000,-15);
2953 //addenemy(ex,ey,dmisc3,0);
2954
2955 }
2956 item_set = 0; //Do not make a drop.
2957 hp = -1000;
2958 return -1;
2959
2960 }
2961 case edSUMMON:
2962 {
2963
2964
2965 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2966 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2967 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2968 for ( int32_t q = 0; q < summon_count; q++ )
2969 {
2970 int32_t x2=16*((zc_oldrand()%12)+2);
2971 int32_t y2=16*((zc_oldrand()%7)+2);
2972 addenemy(
2973 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2974 x2,y2,
2975 dmisc3+0x1000,-15);
2976 //addenemy(ex,ey,dmisc3,0);
2977
2978 }
2979 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2980 return -1;
2981
2982 }
2983
2984 case edEXPLODESMALL:
2985 {
2986 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2987 Ewpns.add(ew);
2988 item_set = 0; //Should we make a drop?
2989 hp = -1000;
2990 return -1;
2991 }
2992
2993
2994 case edEXPLODEHARMLESS:
2995 {
2996 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2997 Ewpns.add(ew);
2998 ew->hyofs = -32768;
2999 item_set = 0; //Should we make a drop?
3000 hp = -1000;
3001 return -1;
3002 }
3003
3004
3005 case edEXPLODELARGE:
3006 {
3007 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3008 Ewpns.add(ew);
3009
3010 hp = -1000;
3011 return -1;
3012 }
3013
3014
3015 case edTRIGGERSECRETS:
3016 {
3017 hidden_entrance(0, true, false, -4);
3018 return -1;
3019 }
3020
3021 case edSTUNORCHINK:
3022
3/4
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
3067 if (stunclk && get_qr(qr_NO_STUNLOCK))
3023 {
3024 sfx(WAV_CHINK,pan(int32_t(x)));
3025 return 1;
3026 }
3027
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 1278 times.
1789 else if(*power <= 0)
3028 {
3029 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
3030 511 sfx(WAV_CHINK,pan(int32_t(x)));
3031 511 return 1;
3032 }
3033 [[fallthrough]];
3034
3035 case edSTUNORIGNORE:
3036
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
4578 if (stunclk && get_qr(qr_NO_STUNLOCK))
3037 {
3038 sfx(WAV_CHINK,pan(int32_t(x)));
3039 return 1;
3040 }
3041
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 1887 times.
2691 else if(*power <= 0)
3042 804 return 0;
3043 [[fallthrough]];
3044
3045 case edSTUNONLY:
3046
7/10
✓ Branch 0 taken 2789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2733 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 2760 times.
✓ Branch 9 taken 29 times.
2789 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3047 {
3048 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3049 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3050 29 return 1;
3051 }
3052
3/4
✓ Branch 0 taken 2135 times.
✓ Branch 1 taken 625 times.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
2760 if (stunclk && get_qr(qr_NO_STUNLOCK))
3053 {
3054 sfx(WAV_CHINK,pan(int32_t(x)));
3055 return 1;
3056 }
3057 else
3058 {
3059 2760 stunclk=160;
3060 2760 sfx(WAV_EHIT,pan(int32_t(x)));
3061
3062 2760 return 1;
3063 }
3064
3065 case edCHINKL1:
3066 if(*power >= 1*game->get_hero_dmgmult()) break;
3067 [[fallthrough]];
3068 case edCHINKL2:
3069
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
3070 [[fallthrough]];
3071 case edCHINKL4:
3072
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
3073 [[fallthrough]];
3074 case edCHINKL6:
3075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
3076 [[fallthrough]];
3077 case edCHINKL8:
3078
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
3079 [[fallthrough]];
3080 case edCHINKL10:
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
3082 [[fallthrough]];
3083 case edCHINK:
3084 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
3085 219 sfx(WAV_CHINK,pan(int32_t(x)));
3086 219 return 1;
3087
3088 case edIGNOREL1:
3089 if(*power > 0) break;
3090 [[fallthrough]];
3091
3092 case edIGNORE:
3093 9312 return 0;
3094
3095 case ed1HKO:
3096 322 *power = hp;
3097 322 return -2;
3098
3099 case ed2x:
3100 {
3101
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3102 //int32_t pow = *power;
3103 //*power = vbound((pow*2),0,214747);
3104 71 return -1;
3105 }
3106 case ed3x:
3107 {
3108 *power = zc_max(1,*power*3);
3109 //int32_t pow = *power;
3110 //*power = vbound((pow*3),0,214747);
3111 return -1;
3112 }
3113
3114 case ed4x:
3115 {
3116 *power = zc_max(1,*power*4);
3117 //int32_t pow = *power;
3118 //*power = vbound((pow*4),0,214747);
3119 return -1;
3120 }
3121
3122
3123 case edHEAL:
3124 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3125 //int32_t pow = *power;
3126 //*power = vbound((pow*-1),0,214747);
3127 //break;
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
3129 79 return -1;
3130 }
3131 /*
3132 case edLEVELDAMAGE:
3133 {
3134 int32_t pow = *power;
3135 int32_t lvl = *level;
3136 *power = vbound((pow*lvl),0,214747);
3137 break;
3138 }
3139 case edLEVELREDUCTION:
3140 {
3141 int32_t pow = *power;
3142 int32_t lvl = *level;
3143 *power = vbound((pow/lvl),0,214747);
3144 break;
3145 }
3146 */
3147
3148 case edQUARTDAMAGE:
3149
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 1 times.
58 *power = zc_max(1,*power/2);
3150
3151 [[fallthrough]];
3152 case edHALFDAMAGE:
3153
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 17 times.
231 *power = zc_max(1,*power/2);
3154 231 break;
3155
3156 case edSWITCH:
3157 {
3158 if(Hero.switchhookclk) return 0; //Already switching!
3159 switch(family)
3160 {
3161 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3162 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3163 return 0;
3164 }
3165 hooked_combopos = -1;
3166 hooked_layerbits = 0;
3167 switching_object = this;
3168 switch_hooked = true;
3169 Hero.doSwitchHook(game->get_switchhookstyle());
3170 if(QMisc.miscsfx[sfxSWITCHED])
3171 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3172 return 1;
3173 }
3174
3175 case 0:
3176 {
3177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53312 times.
53312 if(edef == edefSwitchHook)
3178 return -1;
3179
6/6
✓ Branch 0 taken 13877 times.
✓ Branch 1 taken 39435 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 13848 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
53312 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3180 {
3181 13 sfx(WAV_CHINK,pan(int32_t(x)));
3182 13 return 1;
3183 }
3184
3185 }
3186 53299 }
3187
3188 53627 return -1;
3189 72097 }
3190
3191 72097 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3192 {
3193
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 int wuid = w?w->getUID():0;
3194
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3195
3196
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3197 Lwpns.add(w);
3198 72097 std::vector<int32_t> &ev = FFCore.eventData;
3199 72097 ev.clear();
3200 72097 ev.push_back(*power*10000);
3201 72097 ev.push_back(edef*10000);
3202 72097 ev.push_back(unblockable*10000);
3203 72097 ev.push_back(wpnId*10000);
3204 72097 ev.push_back(0);
3205 72097 ev.push_back(getUID());
3206 72097 ev.push_back(wuid);
3207
3208 72097 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3209 72097 *power = ev[0]/10000;
3210 72097 edef = ev[1]/10000;
3211 72097 unblockable = byte(ev[2]/10000);
3212 72097 wpnId = ev[3] / 10000;
3213 72097 bool nullify = ev[4]!=0;
3214 72097 ev.clear();
3215 72097 int ret = 0;
3216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(!nullify)
3217 {
3218 72097 ret = defendNew(wpnId, power, edef, unblockable);
3219
2/2
✓ Branch 0 taken 18999 times.
✓ Branch 1 taken 53098 times.
72097 if(ret == -1)
3220 {
3221 53098 ev.push_back(*power*10000);
3222 53098 ev.push_back(edef*10000);
3223 53098 ev.push_back(unblockable*10000);
3224 53098 ev.push_back(wpnId*10000);
3225 53098 ev.push_back(0);
3226 53098 ev.push_back(getUID());
3227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53098 times.
53098 ev.push_back(w?w->getUID():0);
3228
3229 53098 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3230 53098 *power = ev[0]/10000;
3231 53098 nullify = ev[4]!=0;
3232 53098 ev.clear();
3233 53098 }
3234 72097 }
3235
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3236 Lwpns.remove(w);
3237
3238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 return nullify ? 0 : ret;
3239 }
3240
3241 53720 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3242 {
3243
2/2
✓ Branch 0 taken 53490 times.
✓ Branch 1 taken 230 times.
53720 if(!realweap) realweap = w;
3244 53720 int32_t wid = getWeaponID(w);
3245
3246 53720 int32_t edef = resolveEnemyDefence(w);
3247
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 52464 times.
53720 if(QHeader.zelda_version > 0x250)
3248 1256 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3249
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 51471 times.
✗ Branch 2 not taken.
52464 switch(wid)
3250 {
3251 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3252 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3253 993 return defend(wpnId, power, edefSCRIPT);
3254
3255 case wWhistle:
3256 return -1;
3257
3258 default:
3259 51471 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3260 }
3261 53720 }
3262
3263
3264 // Check defenses without actually acting on them.
3265 11966 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3266 {
3267
4/10
✓ Branch 0 taken 9574 times.
✓ Branch 1 taken 2059 times.
✓ Branch 2 taken 325 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11966 switch(defense[edef])
3268 {
3269 case edSTUNONLY:
3270 8 return false;
3271 case edSTUNORCHINK:
3272 case edCHINK:
3273 9574 return unblockable&WPNUNB_BLOCK;
3274 case edSTUNORIGNORE:
3275 case edIGNORE:
3276 2059 return unblockable&WPNUNB_IGNR;
3277
3278 case edIGNOREL1:
3279 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3280 case edCHINKL1:
3281 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3282
3283 case edCHINKL2:
3284 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3285
3286 case edCHINKL4:
3287 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3288
3289 case edCHINKL6:
3290 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3291
3292 case edCHINKL8:
3293 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3294 }
3295
3296 325 return true;
3297 11966 }
3298
3299 // Do we do damage?
3300 // 0: takehit returns 0
3301 // 1: takehit returns 1
3302 // -1: do damage
3303 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3304 {
3305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3306 {
3307 switch(defense[edef])
3308 {
3309 case edIGNORE:
3310 return 0;
3311 case edIGNOREL1:
3312 case edSTUNORIGNORE:
3313 if(*power <= 0)
3314 return 0;
3315 }
3316
3317 sfx(WAV_CHINK,pan(int32_t(x)));
3318 return 1;
3319 }
3320
3321
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3322 {
3323 case edSTUNORCHINK:
3324 if(*power <= 0)
3325 {
3326 sfx(WAV_CHINK,pan(int32_t(x)));
3327 return 1;
3328 }
3329
3330 [[fallthrough]];
3331 case edSTUNORIGNORE:
3332 if(*power <= 0)
3333 return 0;
3334
3335 [[fallthrough]];
3336 case edSTUNONLY:
3337 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3338 return 1;
3339
3340 stunclk=160;
3341 sfx(WAV_EHIT,pan(int32_t(x)));
3342 return 1;
3343
3344 case edFREEZE:
3345 frozenclock=-1;
3346 //sfx(WAV_FREEZE,pan(int32_t(x)));
3347 return 1;
3348
3349 case edCHINKL1:
3350 if(*power >= 1*game->get_hero_dmgmult()) break;
3351 [[fallthrough]];
3352 case edCHINKL2:
3353 if(*power >= 2*game->get_hero_dmgmult()) break;
3354 [[fallthrough]];
3355 case edCHINKL4:
3356 if(*power >= 4*game->get_hero_dmgmult()) break;
3357 [[fallthrough]];
3358 case edCHINKL6:
3359 if(*power >= 6*game->get_hero_dmgmult()) break;
3360 [[fallthrough]];
3361 case edCHINKL8:
3362 if(*power >= 8*game->get_hero_dmgmult()) break;
3363 [[fallthrough]];
3364 case edCHINKL10:
3365 if(*power >= 10*game->get_hero_dmgmult()) break;
3366 [[fallthrough]];
3367 case edCHINK:
3368 sfx(WAV_CHINK,pan(int32_t(x)));
3369 return 1;
3370 case edTRIGGERSECRETS:
3371 hidden_entrance(0, true, false, -4);
3372 break;
3373
3374 case edIGNOREL1:
3375 if(*power > 0) break;
3376 [[fallthrough]];
3377 case edIGNORE:
3378 800 return 0;
3379
3380 case ed1HKO:
3381 *power = hp;
3382 return -2;
3383
3384 case ed2x:
3385 {
3386 *power = zc_max(1,*power*2);
3387 //int32_t pow = *power;
3388 //*power = vbound((pow*2),0,214747);
3389 return -1;
3390 }
3391 case ed3x:
3392 {
3393 *power = zc_max(1,*power*3);
3394 //int32_t pow = *power;
3395 //*power = vbound((pow*3),0,214747);
3396 return -1;
3397 }
3398
3399 case ed4x:
3400 {
3401 *power = zc_max(1,*power*4);
3402 //int32_t pow = *power;
3403 //*power = vbound((pow*4),0,214747);
3404 return -1;
3405 }
3406
3407
3408 case edHEAL:
3409 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3410 //int32_t pow = *power;
3411 //*power = vbound((pow*-1),0,214747);
3412 //break;
3413 *power = zc_min(0,*power*-1);
3414 return -1;
3415 }
3416 /*
3417 case edLEVELDAMAGE:
3418 {
3419 int32_t pow = *power;
3420 int32_t lvl = *level;
3421 *power = vbound((pow*lvl),0,214747);
3422 break;
3423 }
3424 case edLEVELREDUCTION:
3425 {
3426 int32_t pow = *power;
3427 int32_t lvl = *level;
3428 *power = vbound((pow/lvl),0,214747);
3429 break;
3430 }
3431 */
3432
3433
3434 case edQUARTDAMAGE:
3435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3436
3437 [[fallthrough]];
3438 case edHALFDAMAGE:
3439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3440 7 break;
3441 }
3442
3443 193 return -1;
3444 993 }
3445
3446 // Defend against a particular item class.
3447 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3448 {
3449 int32_t def=-1;
3450
3451 switch(wpnId)
3452 {
3453 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3454 case wBrang:
3455 def = defend(wpnId, power, edefBRANG);
3456 break;
3457
3458 case wHookshot:
3459 def = defend(wpnId, power, edefHOOKSHOT);
3460 break;
3461
3462 // Anyway...
3463 case wBomb:
3464 def = defend(wpnId, power, edefBOMB);
3465 break;
3466
3467 case wSBomb:
3468 def = defend(wpnId, power, edefSBOMB);
3469 break;
3470
3471 case wArrow:
3472 def = defend(wpnId, power, edefARROW);
3473 break;
3474
3475 case wFire:
3476 def = defend(wpnId, power, edefFIRE);
3477 break;
3478
3479 case wWand:
3480 def = defend(wpnId, power, edefWAND);
3481 break;
3482
3483 case wMagic:
3484 def = defend(wpnId, power, edefMAGIC);
3485 break;
3486
3487 case wHammer:
3488 def = defend(wpnId, power, edefHAMMER);
3489 break;
3490
3491 case wSword:
3492 def = defend(wpnId, power, edefSWORD);
3493 break;
3494
3495 case wBeam:
3496 def = defend(wpnId, power, edefBEAM);
3497 break;
3498
3499 case wRefBeam:
3500 def = defend(wpnId, power, edefREFBEAM);
3501 break;
3502
3503 case wRefMagic:
3504 def = defend(wpnId, power, edefREFMAGIC);
3505 break;
3506
3507 case wRefFireball:
3508 def = defend(wpnId, power, edefREFBALL);
3509 break;
3510
3511 case wRefRock:
3512 def = defend(wpnId, power, edefREFROCK);
3513 break;
3514
3515 case wStomp:
3516 def = defend(wpnId, power, edefSTOMP);
3517 break;
3518
3519 case wCByrna:
3520 def = defend(wpnId, power, edefBYRNA);
3521 break;
3522
3523 case wScript1:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wScript2:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript3:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript4:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript5:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wScript6:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3550 else def = defend(wpnId, power, edefSCRIPT);
3551 break;
3552
3553 case wScript7:
3554 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3555 else def = defend(wpnId, power, edefSCRIPT);
3556 break;
3557
3558 case wScript8:
3559 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3560 else def = defend(wpnId, power, edefSCRIPT);
3561 break;
3562
3563 case wScript9:
3564 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3565 else def = defend(wpnId, power, edefSCRIPT);
3566 break;
3567
3568 case wScript10:
3569 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3570 else def = defend(wpnId, power, edefSCRIPT);
3571 break;
3572
3573 case wWhistle:
3574 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3575 else break;
3576 break;
3577
3578
3579 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3580 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3581 //of the ten if the quest version is lower than N.
3582 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3583 //such as bool UseSeparatedScriptDefences. hah.
3584 default:
3585 //if(wpnId>=wScript1 && wpnId<=wScript10)
3586 // {
3587 // def = defend(wpnId, power, edefSCRIPT);
3588 // }
3589 // }
3590
3591 break;
3592 }
3593
3594 return def;
3595 }
3596
3597 // take damage or ignore it
3598 // -1: damage (if any) dealt
3599 // 1: blocked
3600 // 0: weapon passes through unhindered
3601 159739 int32_t enemy::takehit(weapon *w, weapon* realweap)
3602 {
3603
2/4
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159739 times.
159739 if(fallclk||drownclk) return 0;
3604
2/2
✓ Branch 0 taken 34416 times.
✓ Branch 1 taken 125323 times.
159739 if(!realweap) realweap = w;
3605 159739 int32_t wpnId = w->id;
3606 159739 int32_t power = w->power;
3607 159739 int32_t wpnx = w->x;
3608 159739 int32_t wpny = w->y;
3609 159739 int32_t enemyHitWeapon = w->parentitem;
3610 int32_t wpnDir;
3611 159739 int32_t parent_item = w->parentitem;
3612
3613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159739 times.
159739 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3614 {
3615 wpnId = w->useweapon;
3616 }
3617
3618 // If it's a boomerang that just bounced, use the opposite direction;
3619 // otherwise, it might bypass a shield. This probably won't handle
3620 // every case correctly, but it's better than having shields simply
3621 // not work against boomerangs.
3622
8/8
✓ Branch 0 taken 18979 times.
✓ Branch 1 taken 140760 times.
✓ Branch 2 taken 11895 times.
✓ Branch 3 taken 7084 times.
✓ Branch 4 taken 11291 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 2653 times.
✓ Branch 7 taken 8638 times.
159739 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3623 8638 wpnDir = oppositeDir[w->dir];
3624 else
3625 151101 wpnDir = w->dir;
3626
3627
5/8
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159739 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 761 times.
✓ Branch 7 taken 160110 times.
159739 if(dying || clk<0 || hclk>0 || superman)
3628 761 return 0;
3629
3630 //Prevent boomerang from writing to hitby[] for more than one frame.
3631 //This also prevents stunlock.
3632 //if ( stunclk > 0 ) return 0;
3633 //this needs a rule for boomerangs that cannot stunlock!
3634 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3635 //sigh.
3636
3637 160110 int32_t ret = -1;
3638
3639 // This obscure quest rule...
3640
5/6
✓ Branch 0 taken 77360 times.
✓ Branch 1 taken 82750 times.
✓ Branch 2 taken 77192 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 77192 times.
160110 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3641 {
3642 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3643 168 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3644 168 wpnDir=zc_oldrand()&3;
3645
3646
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
168 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3647 {
3648 59 wpnDir=down;
3649 59 }
3650
4/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 56 times.
109 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3651 {
3652 56 wpnDir=right;
3653 56 }
3654
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 14 times.
53 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3655 {
3656 14 wpnDir=up;
3657 14 }
3658 else
3659 {
3660 39 wpnDir=left;
3661 }
3662 168 }
3663
3664 160110 int32_t xdir = dir;
3665 160110 shieldCanBlock=false;
3666
3667 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
3668
4/4
✓ Branch 0 taken 158266 times.
✓ Branch 1 taken 1844 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 157860 times.
160905 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3669
10/10
✓ Branch 0 taken 13418 times.
✓ Branch 1 taken 13012 times.
✓ Branch 2 taken 18111 times.
✓ Branch 3 taken 152761 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 152703 times.
✓ Branch 6 taken 984 times.
✓ Branch 7 taken 151719 times.
✓ Branch 8 taken 795 times.
✓ Branch 9 taken 150924 times.
158266 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
3670 )
3671 // The hammer should already be dealt with by subclasses (Walker etc.)
3672 {
3673
9/9
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3758 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1317 times.
✓ Branch 8 taken 484 times.
33366 switch(wpnId)
3674 {
3675 // Weapons which shields protect against
3676 case wSword:
3677 case wWand:
3678
1/2
✓ Branch 0 taken 3758 times.
✗ Branch 1 not taken.
3758 if(Hero.getCharging()>0)
3679 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3680
3681 [[fallthrough]];
3682 case wHookshot:
3683 case wHSHandle:
3684 case wBrang:
3685 4021 shieldCanBlock=true;
3686 4273 break;
3687
3688 case wBeam:
3689 case wRefBeam:
3690 // Mirror shielded enemies!
3691 #if 0
3692 if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3693 {
3694 if(wpnId>wEnemyWeapons)
3695 return 0;
3696
3697 sfx(WAV_CHINK,pan(int32_t(x)));
3698 return 1;
3699 }
3700
3701 #endif
3702
3703 [[fallthrough]];
3704 case wRefRock:
3705 case wRefFireball:
3706 case wMagic:
3707 #if 0
3708 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3709 {
3710 sfx(WAV_CHINK,pan(int32_t(x)));
3711 return 3;
3712 }
3713
3714 #endif
3715
3716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(wpnId>wEnemyWeapons)
3717 return 0;
3718
3719 [[fallthrough]];
3720 default:
3721 1597 shieldCanBlock=true;
3722 1597 break;
3723
3724 // Bombs
3725 case wSBomb:
3726 case wBomb:
3727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3728 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3729 {
3730 sfx(WAV_CHINK,pan(int32_t(x)));
3731 return 0;
3732 }
3733 else break;
3734
3735 // Weapons which ignore shields
3736 case wWhistle:
3737 case wHammer:
3738 1 break;
3739
3740 // Weapons which shouldn't be removed by shields
3741 case wLitBomb:
3742 case wLitSBomb:
3743 case wWind:
3744 case wPhantom:
3745 case wSSparkle:
3746 case wBait:
3747 423 return 0;
3748
3749 case wFire:
3750 ;
3751 484 }
3752 6103 }
3753
3754
7/8
✓ Branch 0 taken 72714 times.
✓ Branch 1 taken 53047 times.
✓ Branch 2 taken 211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11966 times.
✓ Branch 5 taken 18964 times.
✓ Branch 6 taken 406 times.
✓ Branch 7 taken 1563 times.
158871 switch(wpnId)
3755 {
3756 case wWhistle: //No longer completely ignore whistle weapons! -Z
3757 {
3758
3759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3760 {
3761 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
3762 211 return 0; break;
3763 }
3764 else
3765 {
3766 w->power = power = itemsbuf[parent_item].misc5;
3767
3768 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3769
3770 if(def <= 0)
3771 {
3772 if ( def == -2 ) hp -= hp;
3773 else hp -= power;
3774 return def;
3775 }
3776 break;
3777 }
3778 break;
3779 }
3780
3781 case wPhantom:
3782 return 0;
3783
3784 case wLitBomb:
3785 case wLitSBomb:
3786 case wBait:
3787 case wWind:
3788 case wSSparkle:
3789 72714 return 0;
3790
3791 case wFSparkle:
3792
3793 // Only take sparkle damage if the sparkle's parent item is not
3794 // defended against.
3795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11966 times.
11966 if(enemyHitWeapon > -1)
3796 {
3797 11966 int32_t p = 0;
3798 11966 int32_t f = itemsbuf[enemyHitWeapon].family;
3799
3800
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11966 times.
11966 switch(f)
3801 {
3802 case itype_arrow:
3803 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3804
3805 break;
3806
3807 case itype_cbyrna:
3808 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3809
3810 break;
3811
3812 case itype_brang:
3813
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 11641 times.
11966 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3814
3815 325 break;
3816
3817 default:
3818 return 0;
3819 }
3820 325 }
3821
3822 325 wpnId = wSword;
3823 325 power = game->get_hero_dmgmult()>>1;
3824 325 goto fsparkle;
3825 break;
3826
3827 case wBrang:
3828 {
3829 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3830 18964 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3831 //preventing stunlock might be best, here. -Z
3832
2/2
✓ Branch 0 taken 4250 times.
✓ Branch 1 taken 14714 times.
18964 if(def >= 0) return def;
3833
3834 // Not hurt by 0-damage weapons
3835
2/2
✓ Branch 0 taken 2271 times.
✓ Branch 1 taken 12443 times.
14714 if(!(flags & guy_bhit))
3836 {
3837 12443 stunclk=160;
3838
3839
3/4
✓ Branch 0 taken 12443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1200 times.
✓ Branch 3 taken 11243 times.
12443 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3840 {
3841
1/2
✓ Branch 0 taken 1200 times.
✗ Branch 1 not taken.
1200 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3842 1200 goto hitclock;
3843 }
3844
3845 11243 break;
3846 }
3847
3848
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1887 times.
2271 if(!power)
3849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1887 times.
1887 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3850 else
3851 384 hp-=power;
3852
3853 2271 goto hitclock;
3854 }
3855
3856 case wHookshot:
3857 {
3858 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3859 406 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3860
3861
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 221 times.
406 if(def >= 0) return def;
3862
3863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3864
3/4
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 6 times.
221 if(swgrab || !(flags & guy_bhit))
3865 {
3866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(!swgrab)
3867 215 stunclk=160;
3868
3869
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3870 {
3871 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3872 goto hitclock;
3873 }
3874
3875 215 break;
3876 }
3877
3878
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3879 else
3880 hp-=power;
3881
3882 6 goto hitclock;
3883 }
3884 break;
3885
3886 case wHSHandle:
3887 {
3888
3/4
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1484 times.
1563 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
3889 79 return 0;
3890
3891
3/4
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
1484 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
391 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3893
3894 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3895
6/8
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 1032 times.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 452 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 370 times.
1801 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3896
6/6
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 651 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 334 times.
452 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
3897 334 return 0;
3898
3899 2182 power = game->get_hero_dmgmult();
3900 2507 }
3901
3902 fsparkle:
3903
3904 [[fallthrough]];
3905 default:
3906 // Work out the defenses!
3907 {
3908 53490 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3909
3910
2/2
✓ Branch 0 taken 14920 times.
✓ Branch 1 taken 38570 times.
53490 if(def >= 0)
3911 14920 return def;
3912
2/2
✓ Branch 0 taken 38280 times.
✓ Branch 1 taken 290 times.
38570 else if(def == -2)
3913 {
3914 290 ret = 0;
3915 290 }
3916 }
3917
3918
2/2
✓ Branch 0 taken 38568 times.
✓ Branch 1 taken 2 times.
77140 if(!power)
3919 {
3920
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3921 2 hp-=1;
3922 else
3923 {
3924 // Don't make a long chain of 'stun' hits
3925 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3926 return 1;
3927
3928
3929 if(!switch_hooked)
3930 stunclk=160;
3931 break;
3932 }
3933 2 }
3934 38568 else hp-=power;
3935
3936 hitclock:
3937 42051 hclk=33;
3938
3939 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3940
2/2
✓ Branch 0 taken 19451 times.
✓ Branch 1 taken 22600 times.
42051 if((dir&2)==(w->dir&2))
3941 {
3942 22600 sclk=(w->dir<<8)+16;
3943 22600 }
3944 42051 }
3945
3946
5/6
✓ Branch 0 taken 38795 times.
✓ Branch 1 taken 14714 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 46788 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6721 times.
53509 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3947 {
3948 6721 fading=fade_blue_poof;
3949 6721 }
3950
3951
6/6
✓ Branch 0 taken 52505 times.
✓ Branch 1 taken 1004 times.
✓ Branch 2 taken 34805 times.
✓ Branch 3 taken 17700 times.
✓ Branch 4 taken 1927 times.
✓ Branch 5 taken 32878 times.
53509 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3952 {
3953
1/2
✓ Branch 0 taken 2931 times.
✗ Branch 1 not taken.
2931 if( hitsfx > 0 ) //user-set hit sound.
3954 {
3955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2931 times.
2931 if (!dying) //don't play the hit sound on death! -Z
3956 2931 sfx(hitsfx, pan(int32_t(x)));
3957 2931 }
3958 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3959 2931 }
3960 else //2.50.2 or earlier
3961 {
3962 50578 sfx(WAV_EHIT, pan(int32_t(x)));
3963 50578 sfx(hitsfx, pan(int32_t(x)));
3964 }
3965
2/2
✓ Branch 0 taken 53499 times.
✓ Branch 1 taken 10 times.
53509 if(family==eeGUY)
3966 10 sfx(WAV_EDEAD, pan(int32_t(x)));
3967
3968 // Penetrating weapons
3969
4/4
✓ Branch 0 taken 52712 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 47718 times.
✓ Branch 3 taken 5791 times.
53509 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3970 {
3971 5791 int32_t item=enemyHitWeapon;
3972
3973
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 5149 times.
5791 if(wpnId==wArrow)
3974 {
3975 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3976
5/6
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
642 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
3977 70 return 0;
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3979 //if(item<0)
3980 else
3981 572 item=current_item_id(itype_arrow);
3982 572 }
3983
3984 else
3985 {
3986
3987 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3988
3/6
✓ Branch 0 taken 5131 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5149 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
3989 return 0;
3990
3991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
5149 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3992 else
3993 //if(item<0)
3994 5149 item=current_item_id(itype_sword);
3995 }
3996 5721 }
3997
3998 53439 return ret;
3999 159027 }
4000
4001 29337462 bool enemy::dont_draw()
4002 {
4003
6/6
✓ Branch 0 taken 29226987 times.
✓ Branch 1 taken 110475 times.
✓ Branch 2 taken 29156080 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 34083 times.
✓ Branch 5 taken 29192904 times.
29337462 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4004 144558 return true;
4005
4006
2/2
✓ Branch 0 taken 286146 times.
✓ Branch 1 taken 28906758 times.
29192904 if(flags&guy_invisible)
4007 286146 return true;
4008
4009
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 28906326 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
28906758 if(flags&lens_only && !lensclk)
4010 return true;
4011
4012
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 28860807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28906758 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
4013 !((flags&lens_only) && (get_qr(qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
4014 return true;
4015
4016 28906758 return false;
4017 29337462 }
4018
4019 #define DRAW_NORMAL 2
4020 #define DRAW_CLOAKED 1
4021 #define DRAW_INVIS 0
4022 // base drawing function to be used by all derived classes instead of
4023 // sprite::draw()
4024 24870233 void enemy::draw(BITMAP *dest)
4025 {
4026 24870233 didScriptThisFrame = false; //Since there's no better place to put it
4027
6/6
✓ Branch 0 taken 24512538 times.
✓ Branch 1 taken 357695 times.
✓ Branch 2 taken 24429888 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 153900 times.
✓ Branch 5 taken 24358638 times.
24870233 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4028 511595 return;
4029
2/2
✓ Branch 0 taken 1573842 times.
✓ Branch 1 taken 22784796 times.
24358638 if(flags&guy_invisible)
4030 1573842 return;
4031
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22784796 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
4032 return;
4033
4034 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4035 // be cloaked if they have "invisible displays as cloaked" checked.
4036
4037 22784796 byte canSee = DRAW_NORMAL;
4038 //Enemy specific stuff
4039
1/2
✓ Branch 0 taken 22784796 times.
✗ Branch 1 not taken.
22784796 if ( editorflags & ENEMY_FLAG1 )
4040 {
4041 canSee = DRAW_INVIS;
4042 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4043 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4044 {
4045 if (game->item[dmisc13])
4046 {
4047 canSee = DRAW_NORMAL;
4048 }
4049 //else if ( lensclk && getlensid.flags SHOWINVIS )
4050 //{
4051 //
4052 //}
4053 //else
4054 //{
4055 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4056 // //otherwisem invisible
4057 //}
4058 }
4059 }
4060 //Room specific
4061
2/2
✓ Branch 0 taken 22592772 times.
✓ Branch 1 taken 192024 times.
22784796 if (tmpscr->flags3&fINVISROOM)
4062 {
4063
4/6
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33839 times.
✓ Branch 3 taken 158185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33839 times.
225863 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33839 times.
33839 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4065 192024 }
4066 //Lens check
4067
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
22784796 if (lensclk)
4068 {
4069
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
4070 {
4071 if (canSee == DRAW_NORMAL)
4072 {
4073 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
4074 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
4075 }
4076 }
4077
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
4078 {
4079
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4080 432 }
4081 26258 }
4082 else
4083 {
4084
2/2
✓ Branch 0 taken 22685122 times.
✓ Branch 1 taken 73416 times.
22758538 if(flags&lens_only)
4085 73416 canSee = DRAW_INVIS;
4086 }
4087
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 22711380 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4088
3/4
✓ Branch 0 taken 22677541 times.
✓ Branch 1 taken 107255 times.
✓ Branch 2 taken 22677541 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4089
4090
2/2
✓ Branch 0 taken 22711380 times.
✓ Branch 1 taken 73416 times.
22784796 if (canSee == DRAW_INVIS)
4091 73416 return;
4092
4093
3/4
✓ Branch 0 taken 22711238 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22711238 times.
22711380 if(fallclk||drownclk)
4094 {
4095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
4096 {
4097 sprite::drawcloaked(dest);
4098 }
4099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
4100 {
4101 142 sprite::draw(dest);
4102 142 }
4103 142 return;
4104 }
4105 22711238 int32_t cshold=cs;
4106
4107
2/2
✓ Branch 0 taken 531444 times.
✓ Branch 1 taken 22179794 times.
22711238 if(dying)
4108 {
4109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if(clk2>=19)
4110 {
4111 if(!(clk2&2))
4112 {
4113 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4114 if (canSee == DRAW_CLOAKED)
4115 {
4116 sprite::drawcloaked(dest);
4117 }
4118 else if (canSee == DRAW_NORMAL)
4119 {
4120 sprite::draw(dest);
4121 }
4122 }
4123 return;
4124 }
4125
4126 531444 flip = 0;
4127 531444 tile = wpnsbuf[spr_death].tile;
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if ( do_animation )
4129 {
4130 531444 int32_t offs = 0;
4131
2/2
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4132 {
4133
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
4134 {
4135 239 spr_death_anim_clk=0;
4136 239 clk2=1;
4137
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
4138 235 death_sfx();
4139 239 }
4140
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
4141 {
4142 4456 ++clk2;
4143
1/2
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4144
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 4437 times.
4456 spr_death_anim_frm *= zc_max(1,txsz);
4145 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4146
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 4382 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4147
4/6
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4217 times.
✓ Branch 5 taken 239 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4148 {
4149 239 spr_death_anim_clk=-1;
4150 239 clk2=1;
4151 239 }
4152 4456 }
4153 4807 tile += spr_death_anim_frm;
4154 4807 }
4155
2/2
✓ Branch 0 taken 79136 times.
✓ Branch 1 taken 447501 times.
526637 else if(BSZ)
4156 {
4157
2/2
✓ Branch 0 taken 62225 times.
✓ Branch 1 taken 16911 times.
79136 offs = zc_min((15-clk2)/3,4);
4158 79136 }
4159
4/4
✓ Branch 0 taken 298376 times.
✓ Branch 1 taken 149125 times.
✓ Branch 2 taken 149027 times.
✓ Branch 3 taken 149349 times.
447501 else if(clk2>6 && clk2<=12)
4160 {
4161 149349 offs = 1;
4162 149349 }
4163
4164
2/2
✓ Branch 0 taken 314434 times.
✓ Branch 1 taken 217010 times.
531444 if(offs)
4165 {
4166
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs *= zc_max(1,txsz);
4167 217010 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4168
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4169 217010 }
4170 531444 tile += offs;
4171 531444 }
4172
4173
6/6
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 447501 times.
✓ Branch 3 taken 79136 times.
✓ Branch 4 taken 129054 times.
✓ Branch 5 taken 318447 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4174 212997 cs = wpnsbuf[spr_death].csets&15;
4175 else
4176 318447 cs = (((clk2+5)>>1)&3)+6;
4177 531444 }
4178
3/4
✓ Branch 0 taken 662995 times.
✓ Branch 1 taken 21516799 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662995 times.
22179794 else if(hclk>0 && getCanFlicker())
4179 {
4180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662995 times.
662995 if(family==eeGANON)
4181 cs=(((hclk-1)>>1)&3)+6;
4182
4/4
✓ Branch 0 taken 613464 times.
✓ Branch 1 taken 49531 times.
✓ Branch 2 taken 174016 times.
✓ Branch 3 taken 439448 times.
662995 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4183 439448 cs=(((hclk-1)>>1)&3)+6;
4184 662995 }
4185 //draw every other frame for flickering enemies
4186
8/10
✓ Branch 0 taken 11349962 times.
✓ Branch 1 taken 11361276 times.
✓ Branch 2 taken 11349962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 569201 times.
✓ Branch 5 taken 10780761 times.
✓ Branch 6 taken 137002 times.
✓ Branch 7 taken 432199 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 137002 times.
22711238 if (is_hitflickerframe() && family != eeGANON && hclk && get_qr(qr_ENEMIESFLICKER) && getCanFlicker())
4187 {
4188
1/2
✓ Branch 0 taken 137002 times.
✗ Branch 1 not taken.
137002 if (game->get_spriteflickercolor())
4189 {
4190 sprite_flicker_transp_passes = game->get_spriteflickertransp();
4191 sprite_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4192 sprite::draw(dest);
4193 }
4194 137002 }
4195 else
4196 {
4197
2/2
✓ Branch 0 taken 33668 times.
✓ Branch 1 taken 22540568 times.
22574236 if (canSee == DRAW_CLOAKED)
4198 {
4199 33668 sprite::drawcloaked(dest);
4200 33668 }
4201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22540568 times.
22540568 else if (canSee == DRAW_NORMAL)
4202 {
4203
1/2
✓ Branch 0 taken 22540568 times.
✗ Branch 1 not taken.
22540568 if ( frozenclock < 0 )
4204 {
4205 if ( frozentile > 0 ) tile = frozentile;
4206 loadpalset(csBOSS,frozencset);
4207 }
4208 22540568 sprite::draw(dest);
4209 22540568 }
4210 }
4211 22711238 cs=cshold;
4212 24870233 }
4213
4214 //old zc bosses
4215 23264120 void enemy::drawzcboss(BITMAP *dest)
4216 {
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23264120 times.
23264120 if(dont_draw())
4218 return;
4219
4220 23264120 int32_t cshold=cs;
4221
4222
2/2
✓ Branch 0 taken 492438 times.
✓ Branch 1 taken 22771682 times.
23264120 if(dying)
4223 {
4224
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 489846 times.
492438 if(clk2>=19)
4225 {
4226
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 1296 times.
2592 if(!(clk2&2))
4227 1296 sprite::drawzcboss(dest);
4228
4229 2592 return;
4230 }
4231
4232 489846 flip = 0;
4233 489846 tile = wpnsbuf[spr_death].tile;
4234
4235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 489846 times.
489846 if ( do_animation )
4236 {
4237
2/2
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4238 {
4239
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
4240 {
4241 2 spr_death_anim_clk=0;
4242 2 clk2=1;
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
4244 2 death_sfx();
4245 2 }
4246
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
4247 {
4248 2 ++clk2;
4249
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm *= zc_max(1,txsz);
4251 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4253
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4254 {
4255 spr_death_anim_clk=-1;
4256 clk2=1;
4257 }
4258 2 }
4259 2186 tile += spr_death_anim_frm;
4260 2186 }
4261
2/2
✓ Branch 0 taken 79248 times.
✓ Branch 1 taken 408412 times.
487660 else if(BSZ)
4262
2/2
✓ Branch 0 taken 62313 times.
✓ Branch 1 taken 16935 times.
79248 tile += zc_min((15-clk2)/3,4);
4263
4/4
✓ Branch 0 taken 272202 times.
✓ Branch 1 taken 136210 times.
✓ Branch 2 taken 135966 times.
✓ Branch 3 taken 136236 times.
408412 else if(clk2>6 && clk2<=12)
4264 136236 ++tile;
4265 489846 }
4266
4267
6/6
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 408412 times.
✓ Branch 3 taken 79248 times.
✓ Branch 4 taken 125904 times.
✓ Branch 5 taken 282508 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4268 207338 cs = wpnsbuf[spr_death].csets&15;
4269 else
4270 282508 cs = (((clk2+5)>>1)&3)+6;
4271 489846 }
4272
2/2
✓ Branch 0 taken 22105172 times.
✓ Branch 1 taken 666510 times.
22771682 else if(hclk>0)
4273 {
4274
2/2
✓ Branch 0 taken 2916 times.
✓ Branch 1 taken 663594 times.
666510 if(family==eeGANON)
4275 2916 cs=(((hclk-1)>>1)&3)+6;
4276
4/4
✓ Branch 0 taken 619253 times.
✓ Branch 1 taken 44341 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 508788 times.
663594 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4277 508788 cs=(((hclk-1)>>1)&3)+6;
4278 666510 }
4279
4280
3/4
✓ Branch 0 taken 167600 times.
✓ Branch 1 taken 23093928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2948 times.
23264476 if((tmpscr->flags3&fINVISROOM) &&
4281
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 164652 times.
167600 !(current_item(itype_amulet)) &&
4282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2948 times.
2948 !(get_qr(qr_LENSSEESENEMIES) &&
4283 2948 lensclk) && family!=eeGANON)
4284 {
4285 2948 sprite::drawcloaked(dest);
4286 2948 }
4287 else
4288 {
4289
6/6
✓ Branch 0 taken 23236088 times.
✓ Branch 1 taken 22492 times.
✓ Branch 2 taken 1090454 times.
✓ Branch 3 taken 22145634 times.
✓ Branch 4 taken 930949 times.
✓ Branch 5 taken 159505 times.
23258580 if(family !=eeGANON && hclk>0 && get_qr(qr_ENEMIESFLICKER))
4290 {
4291
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if (is_hitflickerframe())
4292 {
4293
1/2
✓ Branch 0 taken 15820 times.
✗ Branch 1 not taken.
15820 if (game->get_spriteflickercolor())
4294 {
4295 sprite_flicker_transp_passes = game->get_spriteflickertransp();
4296 sprite_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4297 sprite::drawzcboss(dest);
4298 }
4299 15820 }
4300 else
4301 143685 sprite::drawzcboss(dest);
4302 159505 }
4303 else
4304 23099075 sprite::drawzcboss(dest);
4305 }
4306
4307 23261528 cs=cshold;
4308 23264120 }
4309
4310
4311 // similar to the overblock function--can do up to a 32x32 sprite
4312 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4313 136827 void enemy::drawblock(BITMAP *dest,int32_t mask)
4314 {
4315 136827 int32_t thold=tile;
4316 136827 int32_t t1=tile;
4317 136827 int32_t t2=tile+20;
4318 136827 int32_t t3=tile+1;
4319 136827 int32_t t4=tile+21;
4320
4321
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 136827 times.
136827 switch(mask)
4322 {
4323 case 1:
4324 enemy::drawzcboss(dest);
4325 break;
4326
4327 case 3:
4328 if(flip&2)
4329 zc_swap(t1,t2);
4330
4331 tile=t1;
4332 enemy::drawzcboss(dest);
4333 tile=t2;
4334 yofs+=16;
4335 enemy::drawzcboss(dest);
4336 yofs-=16;
4337 break;
4338
4339 case 5:
4340 t2=tile+1;
4341
4342 if(flip&1)
4343 zc_swap(t1,t2);
4344
4345 tile=t1;
4346 enemy::drawzcboss(dest);
4347 tile=t2;
4348 xofs+=16;
4349 enemy::drawzcboss(dest);
4350 xofs-=16;
4351 break;
4352
4353 case 15:
4354
2/2
✓ Branch 0 taken 130714 times.
✓ Branch 1 taken 6113 times.
136827 if(flip&1)
4355 {
4356 6113 zc_swap(t1,t3);
4357 6113 zc_swap(t2,t4);
4358 6113 }
4359
4360
1/2
✓ Branch 0 taken 136827 times.
✗ Branch 1 not taken.
136827 if(flip&2)
4361 {
4362 zc_swap(t1,t2);
4363 zc_swap(t3,t4);
4364 }
4365
4366 136827 tile=t1;
4367 136827 enemy::drawzcboss(dest);
4368 136827 tile=t2;
4369 136827 yofs+=16;
4370 136827 enemy::drawzcboss(dest);
4371 136827 yofs-=16;
4372 136827 tile=t3;
4373 136827 xofs+=16;
4374 136827 enemy::drawzcboss(dest);
4375 136827 tile=t4;
4376 136827 yofs+=16;
4377 136827 enemy::drawzcboss(dest);
4378 136827 xofs-=16;
4379 136827 yofs-=16;
4380 136827 break;
4381 }
4382
4383 136827 tile=thold;
4384 136827 }
4385
4386 5845877 void enemy::drawshadow(BITMAP *dest, bool translucent)
4387 {
4388
4/4
✓ Branch 0 taken 5415173 times.
✓ Branch 1 taken 430704 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 5009084 times.
5845877 if(dont_draw() || isSideViewGravity())
4389 {
4390 836793 return;
4391 }
4392
4393
2/2
✓ Branch 0 taken 80005 times.
✓ Branch 1 taken 4929079 times.
5009084 if(dying)
4394 {
4395 80005 return;
4396 }
4397
4398
4/4
✓ Branch 0 taken 2116 times.
✓ Branch 1 taken 4926963 times.
✓ Branch 2 taken 147668 times.
✓ Branch 3 taken 4781411 times.
4929079 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4399 4929079 (darkroom))
4400 {
4401 147668 return;
4402 }
4403 else
4404 {
4405
4/4
✓ Branch 0 taken 4563880 times.
✓ Branch 1 taken 217531 times.
✓ Branch 2 taken 4551272 times.
✓ Branch 3 taken 12608 times.
4781411 if(enemycanfall(id, false) && shadowtile == 0)
4406 12608 shadowtile = wpnsbuf[spr_shadow].tile;
4407
4408
5/6
✓ Branch 0 taken 4209361 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 4209361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3991830 times.
✓ Branch 5 taken 217531 times.
4781411 if(z>0 || fakez>0 || !enemycanfall(id, false))
4409 {
4410
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 789465 times.
789581 if(!shadow_overpit(this))
4411 789465 sprite::drawshadow(dest,translucent);
4412 789581 }
4413 }
4414 5845877 }
4415
4416 88213 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4417 {
4418 88213 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4419
4420
1/2
✓ Branch 0 taken 88213 times.
✗ Branch 1 not taken.
88213 if(sub!=NULL)
4421 {
4422 88213 xofs-=mx;
4423 88213 yofs-=my;
4424 88213 enemy::draw(sub);
4425 88213 xofs+=mx;
4426 88213 yofs+=my;
4427 88213 destroy_bitmap(sub);
4428 88213 }
4429 else
4430 enemy::draw(dest);
4431 88213 }
4432
4433 // override hit detection to check for invicibility, stunned, etc
4434 66872480 bool enemy::hit()
4435 {
4436
4/4
✓ Branch 0 taken 66047727 times.
✓ Branch 1 taken 824753 times.
✓ Branch 2 taken 64960106 times.
✓ Branch 3 taken 1087621 times.
66872480 if(dying || hclk>0) return false;
4437 64960106 return sprite::hit();
4438 66872480 }
4439 52704 bool enemy::hit(sprite *s)
4440 {
4441
3/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52264 times.
✓ Branch 3 taken 440 times.
52704 if(!hit() || !s->hit()) return false;
4442 52264 return sprite::hit(s);
4443 52704 }
4444
4445 27517195 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4446 {
4447
2/2
✓ Branch 0 taken 2179304 times.
✓ Branch 1 taken 25337891 times.
27517195 if(!hit()) return false;
4448 25337891 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4449 27517195 }
4450 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4451 {
4452 if(!hit()) return false;
4453 return sprite::hit(tx,ty,txsz2,tysz2);
4454 }
4455
4456 7434715 bool enemy::hit(weapon *w)
4457 {
4458
2/2
✓ Branch 0 taken 851646 times.
✓ Branch 1 taken 6583069 times.
7434715 if(!hit()) return false;
4459
4460
2/2
✓ Branch 0 taken 6581733 times.
✓ Branch 1 taken 1336 times.
6583069 if (replay_version_check(0, 14))
4461 {
4462
4/6
✓ Branch 0 taken 6361773 times.
✓ Branch 1 taken 219960 times.
✓ Branch 2 taken 6361773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6361773 times.
✗ Branch 5 not taken.
6581733 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk)
4463 219960 return false;
4464 6361773 return sprite::hit(w);
4465 }
4466 1336 return w->hit(this);
4467 7434715 }
4468
4469 6078176 bool enemy::can_pitfall(bool checkspawning)
4470 {
4471
4/4
✓ Branch 0 taken 6070221 times.
✓ Branch 1 taken 7955 times.
✓ Branch 2 taken 6068385 times.
✓ Branch 3 taken 9791 times.
6078176 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4472
2/2
✓ Branch 0 taken 6060917 times.
✓ Branch 1 taken 7468 times.
6068385 switch(guysbuf[id&0xFFF].family)
4473 {
4474 case eeAQUA:
4475 case eeDIG:
4476 case eeDONGO:
4477 case eeFAIRY:
4478 case eeGANON:
4479 case eeGHOMA:
4480 case eeGLEEOK:
4481 case eeGUY:
4482 case eeLANM:
4483 case eeMANHAN:
4484 case eeMOLD:
4485 case eeNONE:
4486 case eePATRA:
4487 case eeZORA:
4488 7468 return false; //Disallowed types
4489 default:
4490 6060917 return true;
4491 }
4492 6078176 }
4493 //Handle death
4494 21148622 void enemy::try_death(bool force_kill)
4495 {
4496
8/8
✓ Branch 0 taken 21107695 times.
✓ Branch 1 taken 40927 times.
✓ Branch 2 taken 21107693 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24644 times.
✓ Branch 5 taken 21083049 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 24643 times.
21148622 if(!dying && (force_kill || (hp<=0 && !immortal)))
4497 {
4498 24645 std::vector<int32_t> &ev = FFCore.eventData;
4499 24645 ev.clear();
4500 24645 ev.push_back(10000);
4501 24645 ev.push_back(getUID());
4502
4503 24645 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4504 24645 bool isSaved = !ev[0];
4505 24645 ev.clear();
4506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24645 times.
24645 if(isSaved) return;
4507
4508
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24621 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 22 times.
24645 if(itemguy && (hasitem&2)!=0)
4509 {
4510
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 22 times.
47 for(int32_t i=0; i<items.Count(); i++)
4511 {
4512
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 22 times.
25 if(((item*)items.spr(i))->pickup&ipENEMY)
4513 {
4514
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4515 {
4516 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4517 {
4518 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4519 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4520 }
4521 else
4522 {
4523 if(extend >= 3)
4524 {
4525 items.spr(i)->x = x+(txsz-1)*8;
4526 items.spr(i)->y = y-2+(tysz-1)*8;
4527 }
4528 else
4529 {
4530 items.spr(i)->x = x;
4531 items.spr(i)->y = y - 2;
4532 }
4533 }
4534 items.spr(i)->z = z;
4535 items.spr(i)->fakez = fakez;
4536 }
4537 else
4538 {
4539 22 items.spr(i)->x = x;
4540 22 items.spr(i)->y = y - 2;
4541 }
4542 22 }
4543 25 }
4544 22 }
4545
4546 24645 dying=true;
4547
4548
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 24623 times.
24645 if(fading==fade_flash_die)
4549 22 clk2=19+18*4;
4550 else
4551 {
4552 24623 clk2 = BSZ ? 15 : 19;
4553
4554
2/2
✓ Branch 0 taken 6674 times.
✓ Branch 1 taken 17949 times.
24623 if(fading!=fade_blue_poof)
4555 17949 fading=0;
4556 }
4557
4558
2/2
✓ Branch 0 taken 24621 times.
✓ Branch 1 taken 24 times.
24645 if(itemguy)
4559 {
4560 24 hasitem&=~2;
4561 24 item_set=0;
4562 24 }
4563
4564
6/6
✓ Branch 0 taken 23961 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 19569 times.
✓ Branch 3 taken 4392 times.
✓ Branch 4 taken 644 times.
✓ Branch 5 taken 18925 times.
24645 if(currscr<128 && count_enemy && !script_spawned)
4565 18925 game->guys[(currmap<<7)+currscr]-=1;
4566 24645 }
4567 21148622 }
4568
4569 // --==**==--
4570
4571 // Movement routines that can be used by derived classes as needed
4572
4573 // --==**==--
4574
4575 324351 void enemy::fix_coords(bool bound)
4576 {
4577
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4578
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
4579
4580
4581
2/2
✓ Branch 0 taken 41509 times.
✓ Branch 1 taken 282842 times.
324351 if(bound)
4582 {
4583
1/2
✓ Branch 0 taken 282842 times.
✗ Branch 1 not taken.
282842 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4584 {
4585
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4586
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4587 282842 }
4588 else
4589 {
4590 x=vbound(x, 0_zf,240_zf);
4591 y=vbound(y, 0_zf,160_zf);
4592 }
4593 282842 }
4594
4595
6/10
✓ Branch 0 taken 323337 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 324351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 324351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 324351 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 324351 times.
324351 if(!OUTOFBOUNDS)
4596 {
4597 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4598
4599 if(isSideViewGravity())
4600 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4601 else
4602 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4603 */
4604 324351 do_fix(x, 16, true);
4605
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 323337 times.
324351 if(isSideViewGravity())
4606 1014 do_fix(y,8,true);
4607 323337 else do_fix(y,16,true);
4608 324351 }
4609 324351 }
4610 6036 bool enemy::cannotpenetrate()
4611 {
4612
4/4
✓ Branch 0 taken 5919 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 5900 times.
6036 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4613 }
4614
4615 394 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4616 {
4617 bool ok;
4618 394 int32_t dx = 0, dy = 0;
4619 394 int32_t sv = 8;
4620
4621 //Why is this here??? Why is it needed???
4622 394 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4623
4624
8/9
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 56 times.
✗ Branch 8 not taken.
394 switch(ndir)
4625 {
4626 case 8:
4627 case up:
4628
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
44 if(canfall(id) && isSideViewGravity())
4629 return false;
4630
4631 44 dy = dy1-s;
4632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 special = (special==spw_clipbottomright)?spw_none:special;
4633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4634 44 break;
4635
4636 case 12:
4637 case down:
4638
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
40 if(canfall(id) && isSideViewGravity())
4639 return false;
4640
4641 40 dy = dy2+s;
4642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4643 40 break;
4644
4645 case 14:
4646 case left:
4647 34 dx = dx1-s;
4648 34 sv = ((isSideViewGravity())?7:8);
4649
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4650
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 33 times.
34 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4651 34 break;
4652
4653 case 10:
4654 case right:
4655 55 dx = dx2+s;
4656 55 sv = ((isSideViewGravity())?7:8);
4657
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 50 times.
55 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4658 55 break;
4659
4660 case 9:
4661 case r_up:
4662 66 dx = dx2+s;
4663 66 dy = dy1-s;
4664
3/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 1 times.
131 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4666 66 break;
4667
4668 case 11:
4669 case r_down:
4670 56 dx = dx2+s;
4671 56 dx = dy2+s;
4672
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4674 56 break;
4675
4676 case 13:
4677 case l_down:
4678 43 dx = dx1-s;
4679 43 dy = dy2+s;
4680
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
84 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4682 43 break;
4683
4684 case 15:
4685 case l_up:
4686 56 dx = dx1-s;
4687 56 dy = dy1-s;
4688
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4690 56 break;
4691
4692 default:
4693 db=99;
4694 return true;
4695 }
4696
4697 394 return ok;
4698 394 }
4699
4700
4701
4702
4703 // returns true if next step is ok, false if there is something there
4704 3806334 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4705 {
4706 3806334 bool ok = false; //initialise the var, son't just declare it
4707 3806334 int32_t dx = 0, dy = 0;
4708 3806334 int32_t sv = 8;
4709 3806334 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4710 //Why is this here??? Why is it needed???
4711 3806334 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4716 3806334 bool offgrid = OFFGRID_ENEMY;
4717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 if(!offgrid)
4718 {
4719 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4720
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usehei<16)usehei=16;
4721
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usewid<16)usewid=16;
4722 3806334 }
4723
9/9
✓ Branch 0 taken 708846 times.
✓ Branch 1 taken 565128 times.
✓ Branch 2 taken 629158 times.
✓ Branch 3 taken 634154 times.
✓ Branch 4 taken 290259 times.
✓ Branch 5 taken 347714 times.
✓ Branch 6 taken 321027 times.
✓ Branch 7 taken 306379 times.
✓ Branch 8 taken 3669 times.
3806334 switch(ndir) //need to check every 8 pixels between two points
4724 {
4725 case 8:
4726 case up:
4727 {
4728
4/4
✓ Branch 0 taken 96582 times.
✓ Branch 1 taken 612264 times.
✓ Branch 2 taken 95992 times.
✓ Branch 3 taken 590 times.
708846 if(enemycanfall(id) && isSideViewGravity())
4729 590 return false;
4730
4731 708256 dy = dy1-s;
4732
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708253 times.
708256 special = (special==spw_clipbottomright)?spw_none:special;
4733 708256 tries = usewid/(offgrid ? 8 : 16);
4734 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4735
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 708256 times.
1316075 for ( ; tries > 0; --tries )
4736 {
4737
2/2
✓ Branch 0 taken 98395 times.
✓ Branch 1 taken 609861 times.
708256 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4738 708256 try_x += (offgrid ? 8 : 16);
4739
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if (!ok) break;
4740 607819 }
4741
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if(!ok) break;
4742
1/2
✓ Branch 0 taken 607819 times.
✗ Branch 1 not taken.
607819 if((usewid%16)>0) //Uneven width
4743 {
4744 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4745 }
4746 607819 break;
4747 }
4748 case 12:
4749 case down:
4750 {
4751
4/4
✓ Branch 0 taken 107028 times.
✓ Branch 1 taken 458100 times.
✓ Branch 2 taken 106340 times.
✓ Branch 3 taken 688 times.
565128 if(enemycanfall(id) && isSideViewGravity())
4752 688 return false;
4753
4754 564440 dy = dy2+s;
4755 564440 tries = usewid/(offgrid ? 8 : 16);
4756 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4757
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 564440 times.
1025090 for ( ; tries > 0; --tries )
4758 {
4759
3/4
✓ Branch 0 taken 103361 times.
✓ Branch 1 taken 461079 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 461079 times.
564440 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4760 564440 try_x += (offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if (!ok) break;
4762 460650 }
4763
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if(!ok) break;
4764
1/2
✓ Branch 0 taken 460650 times.
✗ Branch 1 not taken.
460650 if((usewid%16)>0) //Uneven width
4765 {
4766 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4767 }
4768 460650 break;
4769 }
4770 case 14:
4771 case left:
4772 {
4773 629158 dx = dx1-s;
4774 629158 sv = ((isSideViewGravity())?7:0);
4775
4/4
✓ Branch 0 taken 629152 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1272 times.
✓ Branch 3 taken 627880 times.
629158 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4776 629158 tries = usehei/(offgrid ? 8 : 16);
4777 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4778
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 629158 times.
1161818 for ( ; tries > 0; --tries )
4779 {
4780
2/2
✓ Branch 0 taken 95665 times.
✓ Branch 1 taken 533493 times.
629158 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4781 629158 try_y += (offgrid ? 8 : 16);
4782
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if (!ok) break;
4783 532660 }
4784
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if(!ok) break;
4785
1/2
✓ Branch 0 taken 532660 times.
✗ Branch 1 not taken.
532660 if((usehei%16)>0) //Uneven height
4786 {
4787 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4788 }
4789 532660 break;
4790 }
4791 case 10:
4792 case right:
4793 {
4794 634154 dx = dx2+s;
4795 634154 sv = ((isSideViewGravity())?7:0);
4796 634154 tries = usehei/(offgrid ? 8 : 16);
4797 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4798
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 634154 times.
1174344 for ( ; tries > 0; --tries )
4799 {
4800
3/4
✓ Branch 0 taken 93176 times.
✓ Branch 1 taken 540978 times.
✓ Branch 2 taken 540978 times.
✗ Branch 3 not taken.
634154 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4801 634154 try_y += (offgrid ? 8 : 16);
4802
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if (!ok) break;
4803 540190 }
4804
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if(!ok) break;
4805
1/2
✓ Branch 0 taken 540190 times.
✗ Branch 1 not taken.
540190 if((usehei%16)>0) //Uneven height
4806 {
4807 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4808 }
4809 540190 break;
4810 }
4811 case 9:
4812 case r_up:
4813 {
4814 290259 dx = dx2+s;
4815 290259 dy = dy1-s;
4816 290259 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4817 290259 sv = ((isSideViewGravity())?7:0);
4818
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_x > 0; --tries_x )
4819 {
4820 290259 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4821 290259 try_y = 0;
4822
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_y > 0; --tries_y )
4823 {
4824
4/4
✓ Branch 0 taken 286282 times.
✓ Branch 1 taken 3977 times.
✓ Branch 2 taken 283302 times.
✓ Branch 3 taken 2980 times.
573561 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4825
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 281502 times.
283302 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4826 290259 try_y += (offgrid ? 8 : 16);
4827
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4828 280834 }
4829
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280834 times.
280834 if((usehei%16)>0) //Uneven height
4831 {
4832 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4833 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4834 }
4835 280834 try_x += (offgrid ? 8 : 16);
4836 280834 }
4837
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if(!ok) break;
4838
1/2
✓ Branch 0 taken 280834 times.
✗ Branch 1 not taken.
280834 if((usewid%16)>0) //Uneven width
4839 {
4840 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4841 try_y = 0;
4842 for ( ; tries_y > 0; --tries_y )
4843 {
4844 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4845 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4846 try_y += (offgrid ? 8 : 16);
4847 if (!ok) break;
4848 }
4849 if (!ok) break;
4850 if((usehei%16)>0) //Uneven height
4851 {
4852 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4853 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4854 }
4855 }
4856 280834 break;
4857 }
4858 case 11:
4859 case r_down:
4860 {
4861 347714 dx = dx2+s;
4862 347714 dx = dy2+s;
4863 347714 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4864 //sv = ((isSideViewGravity())?7:0);
4865
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_x > 0; --tries_x )
4866 {
4867 347714 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4868 347714 try_y = 0;
4869
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_y > 0; --tries_y )
4870 {
4871
4/4
✓ Branch 0 taken 347575 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 340363 times.
✓ Branch 3 taken 7212 times.
688077 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4872
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 340321 times.
340363 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4873 347714 try_y += (offgrid ? 8 : 16);
4874
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4875 339823 }
4876
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339823 times.
339823 if((usehei%16)>0) //Uneven height
4878 {
4879 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4880 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4881 }
4882 339823 try_x += (offgrid ? 8 : 16);
4883 339823 }
4884
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if(!ok) break;
4885
1/2
✓ Branch 0 taken 339823 times.
✗ Branch 1 not taken.
339823 if((usewid%16)>0) //Uneven width
4886 {
4887 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4888 try_y = 0;
4889 for ( ; tries_y > 0; --tries_y )
4890 {
4891 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4892 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4893 try_y += (offgrid ? 8 : 16);
4894 if (!ok) break;
4895 }
4896 if (!ok) break;
4897 if((usehei%16)>0) //Uneven height
4898 {
4899 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4900 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4901 }
4902 }
4903 339823 break;
4904 }
4905 case 13:
4906 case l_down:
4907 {
4908 321027 dx = dx1-s;
4909 321027 dy = dy2+s;
4910 321027 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4911 //sv = ((isSideViewGravity())?7:0);
4912
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_x > 0; --tries_x )
4913 {
4914 321027 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4915 321027 try_y = 0;
4916
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_y > 0; --tries_y )
4917 {
4918
4/4
✓ Branch 0 taken 315731 times.
✓ Branch 1 taken 5296 times.
✓ Branch 2 taken 313353 times.
✓ Branch 3 taken 2378 times.
634380 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4919
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 313025 times.
313353 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4920 321027 try_y += (offgrid ? 8 : 16);
4921
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4922 312908 }
4923
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312908 times.
312908 if((usehei%16)>0) //Uneven height
4925 {
4926 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4927 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4928 }
4929 312908 try_x += (offgrid ? 8 : 16);
4930 312908 }
4931
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if(!ok) break;
4932
1/2
✓ Branch 0 taken 312908 times.
✗ Branch 1 not taken.
312908 if((usewid%16)>0) //Uneven width
4933 {
4934 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4935 try_y = 0;
4936 for ( ; tries_y > 0; --tries_y )
4937 {
4938 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4939 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4940 try_y += (offgrid ? 8 : 16);
4941 if (!ok) break;
4942 }
4943 if (!ok) break;
4944 if((usehei%16)>0) //Uneven height
4945 {
4946 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4947 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4948 }
4949 }
4950 312908 break;
4951 }
4952 case 15:
4953 case l_up:
4954 {
4955 306379 dx = dx1-s;
4956 306379 dy = dy1-s;
4957 306379 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4958 306379 sv = ((isSideViewGravity())?7:0);
4959
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_x > 0; --tries_x )
4960 {
4961 306379 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4962 306379 try_y = 0;
4963
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_y > 0; --tries_y )
4964 {
4965
4/4
✓ Branch 0 taken 302185 times.
✓ Branch 1 taken 4194 times.
✓ Branch 2 taken 299965 times.
✓ Branch 3 taken 2220 times.
606344 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4966
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 298047 times.
299965 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4967 306379 try_y += (offgrid ? 8 : 16);
4968
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4969 297417 }
4970
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297417 times.
297417 if((usehei%16)>0) //Uneven height
4972 {
4973 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4974 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4975 }
4976 297417 try_x += (offgrid ? 8 : 16);
4977 297417 }
4978
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if(!ok) break;
4979
1/2
✓ Branch 0 taken 297417 times.
✗ Branch 1 not taken.
297417 if((usewid%16)>0) //Uneven width
4980 {
4981 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4982 try_y = 0;
4983 for ( ; tries_y > 0; --tries_y )
4984 {
4985 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4986 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4987 try_y += (offgrid ? 8 : 16);
4988 if (!ok) break;
4989 }
4990 if (!ok) break;
4991 if((usehei%16)>0) //Uneven height
4992 {
4993 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4994 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4995 }
4996 }
4997 297417 break;
4998 }
4999 default:
5000 3669 db=99;
5001 3669 return true;
5002 }
5003 //Z_eventlog("\n");
5004 3801387 return ok;
5005 3806334 }
5006
5007
5008 2471516 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
5009 {
5010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5012
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5013
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5014 2471516 --usewid;
5015 2471516 --usehei;
5016 2471516 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5017 }
5018
5019 663823 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5020 {
5021 663823 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5022
5023
4/4
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 659035 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 1192 times.
663823 if(special==spw_clipright&&ndir==right)
5024 {
5025 1192 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5026 1192 }
5027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5029
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5030
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5031 663823 --usewid;
5032 663823 --usehei;
5033
2/2
✓ Branch 0 taken 357484 times.
✓ Branch 1 taken 306339 times.
663823 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5034 }
5035
5036 65432 bool enemy::canmove(int32_t ndir, bool kb)
5037 {
5038 65432 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5039 }
5040
5041 // 8-directional
5042 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5043 {
5044 394 int32_t ndir=0;
5045
5046 // can move straight, check if it wants to turn
5047
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 9 times.
394 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5048 {
5049
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5050 {
5051 int32_t w = Lwpns.idFirst(wBait);
5052
5053 if(w>=0)
5054 {
5055 int32_t bx = Lwpns.spr(w)->x;
5056 int32_t by = Lwpns.spr(w)->y;
5057
5058 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5059
5060 if(abs(int32_t(y)-by)>14)
5061 {
5062 if(ndir>0) // Already left or right
5063 {
5064 // Making the diagonal directions
5065 ndir += (by<y) ? 2 : 4;
5066 }
5067 else
5068 {
5069 ndir = (by<y) ? up : down;
5070 }
5071 }
5072
5073 if(canmove(ndir,special,false))
5074 {
5075 dir=ndir;
5076 return;
5077 }
5078 }
5079 }
5080
5081 // Homing added.
5082
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(newhoming && (zc_oldrand()&255)<newhoming)
5083 {
5084 ndir = lined_up(8,true);
5085
5086 if(ndir>=0 && canmove(ndir,special,false))
5087 {
5088 dir=ndir;
5089 }
5090
5091 return;
5092 }
5093
5094 385 int32_t r=zc_oldrand();
5095
5096
2/4
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
385 if(newrate>0 && !(r%newrate))
5097 {
5098 385 ndir = ((dir+((r&64)?-1:1))&7)+8;
5099 385 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5100
5101
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
385 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5102 371 dir=ndir;
5103
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5104 11 dir=ndir2;
5105
5106
3/4
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 371 times.
✗ Branch 3 not taken.
385 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5107 // due to numerous lost fractional components. -L
5108 {
5109 x.doFloor();
5110 y.doFloor();
5111 }
5112 385 }
5113
5114 385 return;
5115 }
5116
5117 // can't move straight, must turn
5118 9 int32_t i=0;
5119
5120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for(; i<32; i++) // Try random dir
5121 {
5122 16 ndir=(zc_oldrand()&7)+8;
5123
5124
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9 times.
16 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5125 9 break;
5126 7 }
5127
5128
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(i==32)
5129 {
5130 for(ndir=8; ndir<16; ndir++)
5131 {
5132 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5133 goto ok;
5134 }
5135
5136 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5137 }
5138
5139 ok:
5140 9 dir=ndir;
5141 9 x.doFloor();
5142 9 y.doFloor();
5143 394 }
5144
5145 311413 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5146 {
5147 311413 int32_t ndir=0;
5148
5149 // can move straight, check if it wants to turn
5150
2/2
✓ Branch 0 taken 293564 times.
✓ Branch 1 taken 17849 times.
311413 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5151 {
5152
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 293357 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
293564 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5153 {
5154 101 int32_t i = Lwpns.idFirst(wBait);
5155
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5156 {
5157 weapon *w = (weapon*)Lwpns.spr(i);
5158 if (get_qr(qr_FIND_CLOSEST_BAIT))
5159 {
5160 int32_t currentrange;
5161 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5162 else currentrange = -1;
5163 int curid = i;
5164 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5165 for(; i<Lwpns.Count(); ++i)
5166 {
5167 weapon *lw = (weapon*)Lwpns.spr(i);
5168 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5169 {
5170 currentrange = distance(x, y, lw->x, lw->y);
5171 curid = i;
5172 }
5173 }
5174 i = curid;
5175 if (currentrange == -1) i = -1;
5176 }
5177 else
5178 {
5179 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5180 }
5181 if(i>=0)
5182 {
5183 int32_t bx = Lwpns.spr(i)->x;
5184 int32_t by = Lwpns.spr(i)->y;
5185
5186 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5187
5188 if(abs(int32_t(y)-by)>14)
5189 {
5190 if(ndir>0) // Already left or right
5191 {
5192 // Making the diagonal directions
5193 ndir += (by<y) ? 2 : 4;
5194 }
5195 else
5196 {
5197 ndir = (by<y) ? up : down;
5198 }
5199 }
5200 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5201 if(canmove(ndir,special,false))
5202 {
5203 dir=ndir;
5204 return;
5205 }
5206 }
5207 }
5208 101 }
5209
5210 // Homing added.
5211
4/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 292999 times.
✓ Branch 2 taken 409 times.
✓ Branch 3 taken 156 times.
293564 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5212 {
5213 156 ndir = lined_up(8,true);
5214
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5215
4/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 87 times.
156 if(ndir>=0 && canmove(ndir,special,false))
5216 {
5217 87 dir=ndir;
5218 87 }
5219
5220 156 return;
5221 }
5222
5223 293408 int32_t r=zc_oldrand();
5224
5225
4/4
✓ Branch 0 taken 184141 times.
✓ Branch 1 taken 109267 times.
✓ Branch 2 taken 99386 times.
✓ Branch 3 taken 84755 times.
293408 if(newrate>0 && !(r%newrate))
5226 {
5227 84755 ndir = ((dir+((r&64)?-1:1))&7)+8;
5228 84755 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5229
5230
2/2
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
84755 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5231 81873 dir=ndir;
5232
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 2702 times.
2882 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5233 2702 dir=ndir2;
5234
5235
4/4
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
✓ Branch 2 taken 77990 times.
✓ Branch 3 taken 3883 times.
84755 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5236 // due to numerous lost fractional components. -L
5237 {
5238 3883 x.doFloor();
5239 3883 y.doFloor();
5240 3883 }
5241 84755 }
5242
5243 293408 return;
5244 }
5245
5246 // can't move straight, must turn
5247 17849 int32_t i=0;
5248
5249
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 33819 times.
33847 for(; i<32; i++) // Try random dir
5250 {
5251 33819 ndir=(zc_oldrand()&7)+8;
5252
5253
2/2
✓ Branch 0 taken 15998 times.
✓ Branch 1 taken 17821 times.
33819 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5254 17821 break;
5255 15998 }
5256
5257
2/2
✓ Branch 0 taken 17821 times.
✓ Branch 1 taken 28 times.
17866 if(i==32)
5258 {
5259
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 17 times.
172 for(ndir=8; ndir<16; ndir++)
5260 {
5261
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 11 times.
155 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5262 11 goto ok;
5263 144 }
5264
5265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5266 17 }
5267
5268 ok:
5269 17849 dir=ndir;
5270 17849 x.doFloor();
5271 17849 y.doFloor();
5272 311413 }
5273
5274 307935 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5275 {
5276 307935 newdir_8(newrate,newhoming,special,0,-8,15,15);
5277 307935 }
5278
5279 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5280 {
5281 394 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5282 394 }
5283
5284 // makes the enemy slide backwards when hit
5285 // sclk: first byte is clk, second byte is dir
5286 // makes the enemy slide backwards when hit
5287 // sclk: first byte is clk, second byte is dir
5288 9376002 int32_t enemy::slide()
5289 {
5290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9376002 times.
9376002 if(script_knockback_clk!=0) //scripted knockback
5291 {
5292 sclk = 0;
5293 return 1; //scripted knockback ran
5294 }
5295
5/6
✓ Branch 0 taken 55775 times.
✓ Branch 1 taken 9320227 times.
✓ Branch 2 taken 5384 times.
✓ Branch 3 taken 50391 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5384 times.
9376002 if(sclk==0 || (hp<=0 && !immortal))
5296 9325611 return 0;
5297
5298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50391 times.
50391 if(knockbackflags & FLAG_NOSLIDE)
5299 {
5300 sclk = 0;
5301 if(!OFFGRID_ENEMY)
5302 {
5303 //Fix to grid
5304 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5305 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5306 do_fix(x, 16, true);
5307 do_fix(y, 16, true);
5308 }
5309 return 0;
5310 }
5311
8/10
✓ Branch 0 taken 5089 times.
✓ Branch 1 taken 45302 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 5064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 3796 times.
✓ Branch 7 taken 1268 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
50391 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5312 {
5313 1268 sclk=0;
5314 1268 return 0;
5315 }
5316
5317 49123 --sclk;
5318
5319
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 6052 times.
✓ Branch 2 taken 6364 times.
✓ Branch 3 taken 16287 times.
✓ Branch 4 taken 18763 times.
49123 switch(sclk>>8)
5320 {
5321 case up:
5322 {
5323
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6046 times.
6052 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5324 {
5325 6 sclk=0;
5326 6 return 0;
5327 }
5328
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5372 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 110 times.
6046 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5329
5330 5936 break;
5331 }
5332 case down:
5333 {
5334
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6362 times.
6364 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5335 {
5336 2 sclk=0;
5337 2 return 0;
5338 }
5339
4/4
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 5593 times.
✓ Branch 2 taken 668 times.
✓ Branch 3 taken 101 times.
6362 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5340
5341 6261 break;
5342 }
5343 case left:
5344 {
5345
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14874 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 16274 times.
16287 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5346 {
5347 13 sclk=0;
5348 13 return 0;
5349 }
5350
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14861 times.
✓ Branch 2 taken 1295 times.
✓ Branch 3 taken 118 times.
16274 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5351
5352 16156 break;
5353 }
5354 case right:
5355 {
5356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18763 times.
18763 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5357 {
5358 sclk=0;
5359 return 0;
5360 }
5361
4/4
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 16402 times.
✓ Branch 2 taken 2195 times.
✓ Branch 3 taken 166 times.
18763 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5362 18597 break;
5363 }
5364 }
5365
5366 48607 int32_t move = knockbackSpeed;
5367
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 48607 times.
94695 while(move>0)
5368 {
5369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48607 times.
48607 int32_t thismove = zc_min(8, move);
5370 48607 move -= thismove;
5371 48607 hitdir = (sclk>>8);
5372
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 5936 times.
✓ Branch 2 taken 6261 times.
✓ Branch 3 taken 16156 times.
✓ Branch 4 taken 18597 times.
48607 switch(sclk>>8)
5373 {
5374 case up:
5375 5936 y-=thismove;
5376 5936 break;
5377
5378 case down:
5379 6261 y+=thismove;
5380 6261 break;
5381
5382 case left:
5383 16156 x-=thismove;
5384 16156 break;
5385
5386 case right:
5387 18597 x+=thismove;
5388 18597 break;
5389 }
5390
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 2519 times.
48607 if(!canmove(sclk>>8,(zfix)0,0,true))
5391 {
5392
3/3
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 1460 times.
✓ Branch 2 taken 4 times.
2519 switch(sclk>>8)
5393 {
5394 case up:
5395 case down:
5396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 if(y < 0)
5397 y = 0;
5398
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 865 times.
1055 else if((int32_t(y)&15) > 7)
5399 190 y=(int32_t(y)&0xF0)+16;
5400 else
5401 865 y=(int32_t(y)&0xF0);
5402
5403 1055 break;
5404
5405 case left:
5406 case right:
5407
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1459 times.
1460 if(x < 0)
5408 1 x = 0;
5409
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1027 times.
1459 else if((int32_t(x)&15) > 7)
5410 432 x=(int32_t(x)&0xF0)+16;
5411 else
5412 1027 x=(int32_t(x)&0xF0);
5413
5414 1460 break;
5415 }
5416
5417 2519 sclk=0;
5418 2519 clk3=0;
5419 2519 break;
5420 }
5421 }
5422
5423
2/2
✓ Branch 0 taken 44810 times.
✓ Branch 1 taken 3797 times.
48607 if((sclk&255)==0)
5424 {
5425 //hitdir = -1;
5426 3797 sclk=0;
5427 3797 }
5428 48607 return 2;
5429 9376002 }
5430
5431 bool enemy::can_slide()
5432 {
5433 if(sclk==0 || (hp<=0 && !immortal))
5434 return false;
5435
5436 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5437 {
5438 return false;
5439 }
5440
5441 return true;
5442 }
5443
5444 bool enemy::fslide()
5445 {
5446 if(sclk==0 || (hp<=0 && !immortal))
5447 return false;
5448
5449 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5450 {
5451 sclk=0;
5452 return false;
5453 }
5454
5455 --sclk;
5456
5457 switch(sclk>>8)
5458 {
5459 case up:
5460 if(y<=16)
5461 {
5462 sclk=0;
5463 return false;
5464 }
5465
5466 break;
5467
5468 case down:
5469 if(y>=160)
5470 {
5471 sclk=0;
5472 return false;
5473 }
5474
5475 break;
5476
5477 case left:
5478 if(x<=16)
5479 {
5480 sclk=0;
5481 return false;
5482 }
5483
5484 break;
5485
5486 case right:
5487 if(x>=240)
5488 {
5489 sclk=0;
5490 return false;
5491 }
5492
5493 break;
5494 }
5495 hitdir = (sclk>>8);
5496 switch(sclk>>8)
5497 {
5498 case up:
5499 y-=4;
5500 break;
5501
5502 case down:
5503 y+=4;
5504 break;
5505
5506 case left:
5507 x-=4;
5508 break;
5509
5510 case right:
5511 x+=4;
5512 break;
5513 }
5514
5515 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5516 {
5517 switch(sclk>>8)
5518 {
5519 case up:
5520 case down:
5521 if((int32_t(y)&15) > 7)
5522 y=(int32_t(y)&0xF0)+16;
5523 else
5524 y=(int32_t(y)&0xF0);
5525
5526 break;
5527
5528 case left:
5529 case right:
5530 if((int32_t(x)&15) > 7)
5531 x=(int32_t(x)&0xF0)+16;
5532 else
5533 x=(int32_t(x)&0xF0);
5534
5535 break;
5536 }
5537
5538 sclk=0;
5539 clk3=0;
5540 }
5541
5542 if((sclk&255)==0)
5543 sclk=0;
5544
5545 return true;
5546 }
5547
5548 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5549 {
5550 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5551 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5552 bool ret = sprite::knockback(time, dir, speed);
5553 if(ret) sclk = 0; //kill engine knockback if interrupted
5554 //! Perhaps also set hitdir here, if needed for timing? -Z
5555 return ret;
5556 }
5557
5558 21148620 bool enemy::runKnockback()
5559 {
5560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if((script_knockback_clk&0xFF)==0)
5561 {
5562 21148620 script_knockback_clk = 0;
5563 21148620 return false;
5564 }
5565 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5566 {
5567 return false;
5568 }
5569 int32_t move = script_knockback_speed;
5570 int32_t kb_dir = script_knockback_clk>>8;
5571 --script_knockback_clk;
5572
5573 while(move>0)
5574 {
5575 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5576 move -= thismove;
5577 hitdir = kb_dir;
5578 switch(kb_dir)
5579 {
5580 case r_up:
5581 case l_up:
5582 case up:
5583 y-=thismove;
5584 break;
5585
5586 case r_down:
5587 case l_down:
5588 case down:
5589 y+=thismove;
5590 break;
5591 }
5592 switch(kb_dir)
5593 {
5594 case l_up:
5595 case l_down:
5596 case left:
5597 x-=thismove;
5598 break;
5599
5600 case r_up:
5601 case r_down:
5602 case right:
5603 x+=thismove;
5604 break;
5605 }
5606 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5607 {
5608 if(!canmove(kb_dir,(zfix)0,0,true))
5609 {
5610 script_knockback_clk=0;
5611 clk3=0;
5612 //Fix to grid
5613 switch(kb_dir)
5614 {
5615 case up:
5616 case down:
5617 break;
5618 default:
5619 if(x < 0)
5620 x = 0;
5621 else if((int32_t(x)&15) > 7)
5622 x=(int32_t(x)&0xF0)+16;
5623 else
5624 x=(int32_t(x)&0xF0);
5625 break;
5626 }
5627 switch(kb_dir)
5628 {
5629 case left:
5630 case right:
5631 break;
5632 default:
5633 if(y < 0)
5634 y = 0;
5635 else if((int32_t(y)&15) > 7)
5636 y=(int32_t(y)&0xF0)+16;
5637 else
5638 y=(int32_t(y)&0xF0);
5639 break;
5640 }
5641 break;
5642 }
5643 }
5644 else
5645 {
5646 if(!scr_canplace(x,y,0,true))
5647 {
5648 script_knockback_clk=0;
5649 clk3=0;
5650 //Fix to grid
5651 if (OFFGRID_ENEMY)
5652 {
5653 switch(kb_dir)
5654 {
5655 case up:
5656 case down:
5657 break;
5658 default:
5659 if(x < 0)
5660 x = 0;
5661 else if((int32_t(x)&7) > 3)
5662 x=(int32_t(x)&0xF8)+8;
5663 else
5664 x=(int32_t(x)&0xF8);
5665 break;
5666 }
5667 switch(kb_dir)
5668 {
5669 case left:
5670 case right:
5671 break;
5672 default:
5673 if(y < 0)
5674 y = 0;
5675 else if((int32_t(y)&7) > 3)
5676 y=(int32_t(y)&0xF8)+8;
5677 else
5678 y=(int32_t(y)&0xF8);
5679 break;
5680 }
5681 }
5682 else
5683 {
5684 switch(kb_dir)
5685 {
5686 case up:
5687 case down:
5688 break;
5689 default:
5690 if(x < 0)
5691 x = 0;
5692 else if((int32_t(x)&15) > 7)
5693 x=(int32_t(x)&0xF0)+16;
5694 else
5695 x=(int32_t(x)&0xF0);
5696 break;
5697 }
5698 switch(kb_dir)
5699 {
5700 case left:
5701 case right:
5702 break;
5703 default:
5704 if(y < 0)
5705 y = 0;
5706 else if((int32_t(y)&15) > 7)
5707 y=(int32_t(y)&0xF0)+16;
5708 else
5709 y=(int32_t(y)&0xF0);
5710 break;
5711 }
5712 }
5713 break;
5714 }
5715
5716 }
5717 }
5718 return true;
5719 21148620 }
5720 // changes enemy's direction, checking restrictions
5721 // rate: 0 = no random changes, 16 = always random change
5722 // homing: 0 = none, 256 = always
5723 // grumble 0 = none, 4 = strongest appetite
5724 306188 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5725 {
5726 306188 int32_t ndir=-1;
5727
5728
4/4
✓ Branch 0 taken 73847 times.
✓ Branch 1 taken 232341 times.
✓ Branch 2 taken 26089 times.
✓ Branch 3 taken 47758 times.
306188 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5729 {
5730 47758 int32_t i = Lwpns.idFirst(wBait);
5731
1/2
✓ Branch 0 taken 47758 times.
✗ Branch 1 not taken.
47758 if(i >= 0) //idfirst returns -1 if it can't find any
5732 {
5733 weapon *w = (weapon*)Lwpns.spr(i);
5734 if (get_qr(qr_FIND_CLOSEST_BAIT))
5735 {
5736 int32_t currentrange;
5737 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5738 else currentrange = -1;
5739 int curid = i;
5740 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5741 for(; i<Lwpns.Count(); ++i)
5742 {
5743 weapon *lw = (weapon*)Lwpns.spr(i);
5744 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5745 {
5746 currentrange = distance(x, y, lw->x, lw->y);
5747 curid = i;
5748 }
5749 }
5750 i = curid;
5751 if (currentrange == -1) i = -1;
5752 }
5753 else
5754 {
5755 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5756 }
5757 if (i >= 0)
5758 {
5759 int32_t bx = Lwpns.spr(i)->x;
5760 int32_t by = Lwpns.spr(i)->y;
5761
5762 if(abs(int32_t(y)-by)>14)
5763 {
5764 ndir = (by<y) ? up : down;
5765 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5766 if(canmove(ndir,special,false))
5767 {
5768 dir=ndir;
5769 return;
5770 }
5771 }
5772
5773 ndir = (bx<x) ? left : right;
5774 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5775 if(canmove(ndir,special,false))
5776 {
5777 dir=ndir;
5778 return;
5779 }
5780 }
5781 }
5782 47758 }
5783
5784
2/2
✓ Branch 0 taken 209238 times.
✓ Branch 1 taken 96950 times.
306188 if((zc_oldrand()&255)<abs(newhoming))
5785 {
5786 96950 ndir = lined_up(8,false);
5787
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96950 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5788
4/4
✓ Branch 0 taken 25542 times.
✓ Branch 1 taken 71408 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 22186 times.
96950 if(ndir>=0 && canmove(ndir,special,false))
5789 {
5790 22186 dir=ndir;
5791 22186 return;
5792 }
5793 74764 }
5794
5795 284002 int32_t i=0;
5796
5797
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 634621 times.
635878 for(; i<32; i++)
5798 {
5799 634621 int32_t r=zc_oldrand();
5800
5801
2/2
✓ Branch 0 taken 194900 times.
✓ Branch 1 taken 439721 times.
634621 if((r&15)<newrate)
5802 194900 ndir=(r>>4)&3;
5803 else
5804 439721 ndir=dir;
5805
5806
2/2
✓ Branch 0 taken 351876 times.
✓ Branch 1 taken 282745 times.
634621 if(canmove(ndir,special,false))
5807 282745 break;
5808 351876 }
5809
5810
2/2
✓ Branch 0 taken 282745 times.
✓ Branch 1 taken 1257 times.
284431 if(i==32)
5811 {
5812
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 429 times.
3999 for(ndir=0; ndir<4; ndir++)
5813 {
5814
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 828 times.
3570 if(canmove(ndir,special,false))
5815 828 goto ok;
5816 2742 }
5817
5818
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 369 times.
429 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5819 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5820 429 }
5821
5822 ok:
5823 284002 dir = ndir;
5824 306188 }
5825
5826 1092 void enemy::newdir()
5827 {
5828 1092 newdir(4,0,spw_none);
5829 1092 }
5830
5831 zfix enemy::distance_left()
5832 {
5833 int32_t a2=x.getInt();
5834 int32_t b2=y.getInt();
5835
5836 switch(dir)
5837 {
5838 case up:
5839 return (zfix)(b2&0xF);
5840
5841 case down:
5842 return (zfix)(16-(b2&0xF));
5843
5844 case left:
5845 return (zfix)(a2&0xF);
5846
5847 case right:
5848 return (zfix)(16-(a2&0xF));
5849 }
5850
5851 return (zfix)0;
5852 }
5853
5854 // keeps walking around
5855 226860 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5856 {
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226860 times.
226860 if(slide())
5858 return;
5859
5860
8/12
✓ Branch 0 taken 224557 times.
✓ Branch 1 taken 2303 times.
✓ Branch 2 taken 224557 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222559 times.
✓ Branch 5 taken 1998 times.
✓ Branch 6 taken 222559 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 222559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 222559 times.
226860 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5861 4301 return;
5862
5863
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 207187 times.
222559 if(clk3<=0)
5864 {
5865 15372 fix_coords(true);
5866 15372 newdir(newrate,newhoming,special);
5867
5868
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if(step==0)
5869 clk3=0;
5870 else
5871 15372 clk3=int32_t(16.0/step);
5872 15372 }
5873
2/2
✓ Branch 0 taken 207166 times.
✓ Branch 1 taken 21 times.
207187 else if(scored)
5874 {
5875 21 dir^=1;
5876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5877 else clk3=32767;
5878 21 }
5879
5880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222559 times.
222559 if (step != 0) --clk3;
5881 222559 move(step);
5882 226860 }
5883
5884 void enemy::constant_walk()
5885 {
5886 constant_walk(4,0,spw_none);
5887 }
5888
5889 18230 int32_t enemy::pos(int32_t newx,int32_t newy)
5890 {
5891 18230 return (newy<<8)+newx;
5892 }
5893
5894 // for variable step rates
5895 234267 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5896 {
5897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
234267 if(slide())
5898 return;
5899
5900
10/14
✓ Branch 0 taken 234267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 228560 times.
✓ Branch 5 taken 5707 times.
✓ Branch 6 taken 221271 times.
✓ Branch 7 taken 7289 times.
✓ Branch 8 taken 200047 times.
✓ Branch 9 taken 21224 times.
✓ Branch 10 taken 200047 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 200047 times.
✗ Branch 13 not taken.
234267 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5901 34220 return;
5902
5903 200047 zfix dx = (zfix)0;
5904 200047 zfix dy = (zfix)0;
5905
5906
5/9
✓ Branch 0 taken 43624 times.
✓ Branch 1 taken 44366 times.
✓ Branch 2 taken 53763 times.
✓ Branch 3 taken 56539 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1755 times.
200047 switch(dir)
5907 {
5908 case 8:
5909 case up:
5910 43624 dy-=step;
5911 43624 break;
5912
5913 case 12:
5914 case down:
5915 44366 dy+=step;
5916 44366 break;
5917
5918 case 14:
5919 case left:
5920 53763 dx-=step;
5921 53763 break;
5922
5923 case 10:
5924 case right:
5925 56539 dx+=step;
5926 56539 break;
5927
5928 case 15:
5929 case l_up:
5930 dx-=step;
5931 dy-=step;
5932 break;
5933
5934 case 9:
5935 case r_up:
5936 dx+=step;
5937 dy-=step;
5938 break;
5939
5940 case 13:
5941 case l_down:
5942 dx-=step;
5943 dy+=step;
5944 break;
5945
5946 case 11:
5947 case r_down:
5948 dx+=step;
5949 dy+=step;
5950 break;
5951 }
5952
5953
8/8
✓ Branch 0 taken 95284 times.
✓ Branch 1 taken 104763 times.
✓ Branch 2 taken 12002 times.
✓ Branch 3 taken 83282 times.
✓ Branch 4 taken 5443 times.
✓ Branch 5 taken 6559 times.
✓ Branch 6 taken 193819 times.
✓ Branch 7 taken 6228 times.
200047 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5954 194604 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5955 {
5956 6228 fix_coords();
5957 6228 newdir(newrate,newhoming,special);
5958 6228 clk3=pos(x,y);
5959 6228 }
5960
5961 200047 move(step);
5962 234267 }
5963
5964 // pauses for a while after it makes a complete move (to a new square)
5965 7485806 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5966 {
5967
4/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 7443999 times.
✓ Branch 2 taken 33602 times.
✓ Branch 3 taken 8205 times.
7485806 if(sclk && clk2)
5968 {
5969 8205 clk3=0;
5970 8205 }
5971
5972
11/14
✓ Branch 0 taken 7448916 times.
✓ Branch 1 taken 36890 times.
✓ Branch 2 taken 7448916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7448916 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7146105 times.
✓ Branch 7 taken 302811 times.
✓ Branch 8 taken 7019314 times.
✓ Branch 9 taken 126791 times.
✓ Branch 10 taken 7017542 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7017542 times.
7485806 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5973 {
5974 468264 return;
5975 }
5976
5977
2/2
✓ Branch 0 taken 1420795 times.
✓ Branch 1 taken 5596747 times.
7017542 if(clk2>0)
5978 {
5979 1420795 --clk2;
5980 1420795 return;
5981 }
5982
5983
2/2
✓ Branch 0 taken 243580 times.
✓ Branch 1 taken 5353167 times.
5596747 if(clk3<=0)
5984 {
5985 243580 fix_coords(true);
5986 243580 newdir(newrate,newhoming,special);
5987 243580 clk3=int32_t(16.0/step);
5988
2/2
✓ Branch 0 taken 243520 times.
✓ Branch 1 taken 60 times.
243580 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243580 times.
243580 if(clk2<0)
5990 {
5991 clk2=0;
5992 }
5993
2/2
✓ Branch 0 taken 35125 times.
✓ Branch 1 taken 208455 times.
243580 else if((zc_oldrand()&15)<newhrate)
5994 {
5995 35125 clk2=haltcnt;
5996 35125 return;
5997 }
5998 208455 }
5999
2/2
✓ Branch 0 taken 5351685 times.
✓ Branch 1 taken 1482 times.
5353167 else if(scored)
6000 {
6001 1482 dir^=1;
6002
6003
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1481 times.
1482 if (step != 0) clk3=int32_t(16.0/step)-clk3;
6004 1 else clk3=32767;
6005 1482 }
6006
6007
2/2
✓ Branch 0 taken 37087 times.
✓ Branch 1 taken 5524535 times.
5561622 if (step != 0) --clk3;
6008 5561622 move(step);
6009 7485806 }
6010
6011 // 8-directional movement, aligns to 8 pixels
6012 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
6013 {
6014 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6015 return;
6016
6017 if(clk3<=0)
6018 {
6019 newdir_8(newrate,newhoming,special);
6020 clk3=int32_t(8.0/step);
6021 if (step == 0) clk3 = 32767;
6022 }
6023
6024 if (step != 0) --clk3;
6025 move(step);
6026 }
6027 // 8-directional movement, aligns to 8 pixels
6028 84876 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6029 {
6030
6/12
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84876 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84876 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84876 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 84876 times.
84876 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6031 return;
6032
6033
2/2
✓ Branch 0 taken 78734 times.
✓ Branch 1 taken 6142 times.
84876 if(clk3<=0)
6034 {
6035 6142 newdir_8(newrate,newhoming,special);
6036 6142 clk3=int32_t(8.0/step);
6037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6142 times.
6142 if (step == 0) clk3 = 32767;
6038 6142 }
6039
6040
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if (step != 0) --clk3;
6041 84876 move(step);
6042 84876 }
6043
6044 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6045 {
6046 if(clk<0 || dying || stunclk || watch || frozenclock)
6047 return;
6048
6049 if(!canmove(dir,step,special,false))
6050 clk3=0;
6051
6052 if(clk2>0)
6053 {
6054 --clk2;
6055 return;
6056 }
6057
6058 if(clk3<=0)
6059 {
6060 newdir_8(newrate,newhoming,special);
6061 clk3=newclk;
6062
6063 if(clk2<0)
6064 {
6065 clk2=0;
6066 }
6067 else if((zc_oldrand()&15)<newhrate)
6068 {
6069 newdir_8(newrate,newhoming,special);
6070 clk2=haltcnt;
6071 return;
6072 }
6073 }
6074
6075 --clk3;
6076 move(step);
6077 }
6078
6079 // 8-directional movement, no alignment
6080 2513985 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6081 {
6082
9/12
✓ Branch 0 taken 2408462 times.
✓ Branch 1 taken 105523 times.
✓ Branch 2 taken 2408462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2386969 times.
✓ Branch 5 taken 21493 times.
✓ Branch 6 taken 2377143 times.
✓ Branch 7 taken 9826 times.
✓ Branch 8 taken 2377143 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2377143 times.
2513985 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6083 136842 return;
6084
6085
2/2
✓ Branch 0 taken 2360249 times.
✓ Branch 1 taken 16894 times.
2377143 if(!canmove(dir,step,special,false))
6086 16894 clk3=0;
6087
6088
2/2
✓ Branch 0 taken 2075350 times.
✓ Branch 1 taken 301793 times.
2377143 if(clk3<=0)
6089 {
6090 301793 newdir_8(newrate,newhoming,special);
6091 301793 clk3=newclk;
6092 301793 }
6093
6094 2377143 --clk3;
6095 2377143 move(step);
6096 2513985 }
6097
6098 // same as above but with variable enemy size
6099 52535 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6100 {
6101
8/12
✓ Branch 0 taken 51768 times.
✓ Branch 1 taken 767 times.
✓ Branch 2 taken 51768 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 51768 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 51717 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 51717 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 51717 times.
52535 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6102 818 return;
6103
6104
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 517 times.
51717 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6105 517 clk3=0;
6106
6107
2/2
✓ Branch 0 taken 48239 times.
✓ Branch 1 taken 3478 times.
51717 if(clk3<=0)
6108 {
6109 3478 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6110 3478 clk3=newclk;
6111 3478 }
6112
6113 51717 --clk3;
6114 51717 move(step);
6115 52535 }
6116
6117 // the variable speed floater movement
6118 // ms is max speed
6119 // ss is step speed
6120 // s is step count
6121 // p is pause count
6122 // g is graduality :)
6123 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6124 2107695 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6125 {
6126 2107695 ++clk2;
6127 2107695 byte over_pit = overpit(this);
6128
6129
4/4
✓ Branch 0 taken 424954 times.
✓ Branch 1 taken 1682741 times.
✓ Branch 2 taken 424687 times.
✓ Branch 3 taken 267 times.
2107695 if(dmisc1 && over_pit) p = 0;
6130
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 36911 times.
✓ Branch 2 taken 849849 times.
✓ Branch 3 taken 1135402 times.
✓ Branch 4 taken 85533 times.
2107695 switch(movestatus)
6131 {
6132 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6133 //! if the conditions prevent it, we jump back to case 2.
6134 case 0: // paused
6135
2/2
✓ Branch 0 taken 36222 times.
✓ Branch 1 taken 689 times.
36911 if(clk2>=p)
6136 {
6137 689 movestatus=1;
6138 689 clk2=0;
6139 689 }
6140
6141 36911 break;
6142
6143 case 1: // speeding up
6144
1/2
✓ Branch 0 taken 849849 times.
✗ Branch 1 not taken.
849849 if (s >= 0)
6145 {
6146
2/2
✓ Branch 0 taken 844313 times.
✓ Branch 1 taken 5536 times.
849849 if(clk2<g*s)
6147 {
6148
2/2
✓ Branch 0 taken 790189 times.
✓ Branch 1 taken 54124 times.
844313 if(!((clk2-1)%g))
6149 54124 step+=ss;
6150 844313 }
6151 else
6152 {
6153 5536 movestatus=2;
6154 5536 clk2=0;
6155 }
6156 849849 }
6157 else
6158 {
6159 if(step < ms)
6160 {
6161 if(!((clk2-1)%g))
6162 {
6163 step+=ss;
6164 if (step >= ms) step = ms;
6165 }
6166 }
6167 else
6168 {
6169 step = ms;
6170 movestatus=2;
6171 clk2=0;
6172 }
6173 }
6174
6175 849849 break;
6176
6177 case 2: // normal
6178 1135402 step=ms;
6179
6180
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1135402 times.
✓ Branch 2 taken 237381 times.
✓ Branch 3 taken 898021 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 898021 times.
✓ Branch 6 taken 896841 times.
✓ Branch 7 taken 1180 times.
1135402 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6181 {
6182
1/2
✓ Branch 0 taken 1180 times.
✗ Branch 1 not taken.
1180 if (s >= 0) step=ss*s;
6183 else step=ms;
6184 1180 movestatus=3;
6185 1180 clk2=0;
6186 1180 }
6187
6188 1135402 break;
6189
6190 case 3: // slowing down
6191
1/2
✓ Branch 0 taken 85533 times.
✗ Branch 1 not taken.
85533 if (s >= 0)
6192 {
6193
2/2
✓ Branch 0 taken 84707 times.
✓ Branch 1 taken 826 times.
85533 if(clk2<=g*s)
6194 {
6195 { //don't slow down over pits
6196
6197
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84695 times.
84707 if(over_pit)
6198 {
6199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
6200 {
6201 step=ms;
6202 }
6203 12 }
6204 else //can slow down
6205 {
6206
4/4
✓ Branch 0 taken 5242 times.
✓ Branch 1 taken 79453 times.
✓ Branch 2 taken 4970 times.
✓ Branch 3 taken 272 times.
84695 if(!(clk2%g) && !dmisc1)
6207 4970 step-=ss;
6208 }
6209 }
6210
6211
6212 84707 }
6213 else
6214 {
6215 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6216 //this doesn't help keese, as they have a z of 0.
6217 //they always nee to run this check.
6218 {
6219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
826 if(over_pit &&!dmisc1)
6220 {
6221 --clk2; //if over a pit, don't land, and revert clock change
6222 }
6223 else //can land safely
6224 {
6225 826 movestatus=0;
6226
3/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
826 if(dmisc1&&!over_pit)
6227 468 step=0;
6228 826 clk2=0;
6229 }
6230 }
6231
6232 }
6233 85533 }
6234 else
6235 {
6236 if(step > 0)
6237 {
6238 if(over_pit)
6239 {
6240 if(dmisc1)
6241 {
6242 step=ms;
6243 }
6244 }
6245 else //can slow down
6246 {
6247 if(!(clk2%g))
6248 step-=ss;
6249 }
6250 }
6251 else
6252 {
6253 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6254 //this doesn't help keese, as they have a z of 0.
6255 //they always nee to run this check.
6256 if(over_pit)
6257 {
6258 step+=ss; //if over a pit, don't land, and revert clock change
6259 }
6260 else //can land safely
6261 {
6262 movestatus=0;
6263 step=0;
6264 clk2=0;
6265 }
6266 }
6267 }
6268
6269 85533 break;
6270 }
6271
6272
2/2
✓ Branch 0 taken 1139758 times.
✓ Branch 1 taken 967937 times.
2107695 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6273 2107695 }
6274
6275 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6276 {
6277 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6278 }
6279
6280 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6281 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6282 505599 int32_t enemy::lined_up(int32_t range, bool dir8)
6283 {
6284 505599 int32_t lx = Hero.getX();
6285 505599 int32_t ly = Hero.getY();
6286
6287
2/2
✓ Branch 0 taken 19794 times.
✓ Branch 1 taken 485805 times.
505599 if(abs(lx-int32_t(x))<=range)
6288 {
6289
2/2
✓ Branch 0 taken 7913 times.
✓ Branch 1 taken 11881 times.
19794 if(ly<y)
6290 {
6291 7913 return up;
6292 }
6293
6294 11881 return down;
6295 }
6296
6297
2/2
✓ Branch 0 taken 23666 times.
✓ Branch 1 taken 462139 times.
485805 if(abs(ly-int32_t(y))<=range)
6298 {
6299
2/2
✓ Branch 0 taken 12185 times.
✓ Branch 1 taken 11481 times.
23666 if(lx<x)
6300 {
6301 12185 return left;
6302 }
6303
6304 11481 return right;
6305 }
6306
6307
2/2
✓ Branch 0 taken 94764 times.
✓ Branch 1 taken 367375 times.
462139 if(dir8)
6308 {
6309
2/2
✓ Branch 0 taken 130299 times.
✓ Branch 1 taken 237076 times.
367375 if(abs(lx-x)-abs(ly-y)<=range)
6310 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6311 {
6312
2/2
✓ Branch 0 taken 55233 times.
✓ Branch 1 taken 75066 times.
130299 if(ly<y)
6313 {
6314
2/2
✓ Branch 0 taken 32006 times.
✓ Branch 1 taken 23227 times.
55233 if(lx<x)
6315 {
6316 32006 return l_up;
6317 }
6318 else
6319 {
6320 23227 return r_up;
6321 }
6322 }
6323 else
6324 {
6325
2/2
✓ Branch 0 taken 38204 times.
✓ Branch 1 taken 36862 times.
75066 if(lx<x)
6326 {
6327 36862 return l_down;
6328 }
6329 else
6330 {
6331 38204 return r_down;
6332 }
6333 }
6334 }
6335 237076 }
6336
6337 331840 return -1;
6338 505599 }
6339
6340 // returns true if Hero is within 'range' pixels of the enemy
6341 13988 bool enemy::HeroInRange(int32_t range)
6342 {
6343 13988 int32_t lx = Hero.getX();
6344 13988 int32_t ly = Hero.getY();
6345
2/2
✓ Branch 0 taken 11733 times.
✓ Branch 1 taken 2255 times.
13988 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6346 }
6347
6348 // place the enemy in line with Hero (red wizzrobes)
6349 2334 void enemy::place_on_axis(bool floater, bool solid_ok)
6350 {
6351
6/6
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 2129 times.
✓ Branch 3 taken 205 times.
✓ Branch 4 taken 241 times.
✓ Branch 5 taken 1888 times.
2334 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6352
6/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 2216 times.
✓ Branch 2 taken 1980 times.
✓ Branch 3 taken 354 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 1862 times.
2334 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6353 2334 int32_t pos2=zc_oldrand()%23;
6354 2334 int32_t tried=0;
6355 2334 bool last_resort,placed=false;
6356
6357
6358 2334 do
6359 {
6360
2/2
✓ Branch 0 taken 2419 times.
✓ Branch 1 taken 1712 times.
4131 if(pos2<14)
6361 {
6362 2419 x=(pos2<<4)+16;
6363 2419 y=ly;
6364 2419 }
6365 else
6366 {
6367 1712 x=lx;
6368 1712 y=((pos2-14)<<4)+16;
6369 }
6370
6371 // Don't commit to a last resort if position is out of bounds.
6372
6/6
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 3808 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 127 times.
✓ Branch 5 taken 3681 times.
4131 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6373
6374
4/4
✓ Branch 0 taken 2148 times.
✓ Branch 1 taken 1983 times.
✓ Branch 2 taken 3739 times.
✓ Branch 3 taken 1591 times.
4131 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6375 {
6376 // Red Wizzrobes should be able to appear on water, but not other
6377 // solid combos; however, they could appear on solid combos in 2.10,
6378 // and some quests depend on that.
6379
4/4
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 3582 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 2334 times.
5722 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6380 5722 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6381 2334 placed=true;
6382 5722 }
6383
6384
3/6
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1797 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4817 if(!placed && tried>=22 && last_resort)
6385 {
6386 placed=true;
6387 }
6388
6389 4817 ++tried;
6390 4817 pos2=(pos2+3)%23;
6391
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
4817 }
6392 4817 while(!placed);
6393
6394
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 854 times.
3020 if(y==ly)
6395 2166 dir=(x<lx)?right:left;
6396 else
6397 854 dir=(y<ly)?down:up;
6398
6399 3020 clk2=tried;
6400 3020 }
6401
6402 10524416 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6403 {
6404 10524416 int32_t t = o_tile;
6405 10524416 int32_t b = o_tile;
6406
6407 // Darknuts, but also Wizzrobes and Wallmasters
6408
3/4
✓ Branch 0 taken 3963465 times.
✓ Branch 1 taken 6178051 times.
✓ Branch 2 taken 382900 times.
✗ Branch 3 not taken.
10524416 switch(family)
6409 {
6410 case eeWALK:
6411
5/6
✓ Branch 0 taken 373692 times.
✓ Branch 1 taken 5804359 times.
✓ Branch 2 taken 264807 times.
✓ Branch 3 taken 108885 times.
✓ Branch 4 taken 264807 times.
✗ Branch 5 not taken.
6178051 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6412 {
6413 264807 tile=s_tile;
6414 264807 t=s_tile;
6415 264807 b=s_tile;
6416 264807 }
6417
6418 6178051 break;
6419
6420 case eeTRAP:
6421
4/6
✓ Branch 0 taken 141238 times.
✓ Branch 1 taken 241662 times.
✓ Branch 2 taken 141238 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 141238 times.
382900 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
6422 {
6423 141238 tile=s_tile;
6424 141238 t=s_tile;
6425 141238 b=s_tile;
6426 141238 }
6427
6428 382900 break;
6429
6430 case eeSPINTILE:
6431 if(misc>=96 && do_animation)
6432 {
6433 tile=o_tile+frames*ndir;
6434 t=tile;
6435 }
6436
6437 break;
6438 }
6439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10524416 times.
10524416 if ( do_animation )
6440 {
6441
4/6
✓ Branch 0 taken 163042 times.
✓ Branch 1 taken 10361374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266817 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10094557 times.
10524416 if(ndir!=0) switch(frames)
6442 {
6443 case 2:
6444 266817 tiledir_small(dir,ndir==4);
6445 266817 break;
6446
6447 case 3:
6448 tiledir_three(dir);
6449 break;
6450
6451 case 4:
6452 10094557 tiledir(dir,ndir==4);
6453 10094557 break;
6454 10361374 }
6455
6456
2/2
✓ Branch 0 taken 6178051 times.
✓ Branch 1 taken 4346365 times.
10524416 if(family==eeWALK)
6457
6/6
✓ Branch 0 taken 6167527 times.
✓ Branch 1 taken 10524 times.
✓ Branch 2 taken 4638452 times.
✓ Branch 3 taken 1539599 times.
✓ Branch 4 taken 1537069 times.
✓ Branch 5 taken 2530 times.
6178051 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6458 else
6459 4346365 tile+=f4;
6460 10524416 }
6461 10524416 return b;
6462 }
6463
6464 void enemy::tiledir_three(int32_t ndir)
6465 {
6466 if ( !do_animation ) return;
6467 flip=0;
6468
6469 switch(ndir)
6470 {
6471 case right:
6472 tile+=3;
6473 [[fallthrough]];
6474
6475 case left:
6476 tile+=3;
6477 [[fallthrough]];
6478
6479 case down:
6480 tile+=3;
6481 [[fallthrough]];
6482
6483 case up:
6484 break;
6485 }
6486 }
6487
6488 266817 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6489 {
6490
1/2
✓ Branch 0 taken 266817 times.
✗ Branch 1 not taken.
266817 if ( !do_animation ) return;
6491 266817 flip=0;
6492
6493
8/9
✓ Branch 0 taken 53728 times.
✓ Branch 1 taken 54633 times.
✓ Branch 2 taken 67625 times.
✓ Branch 3 taken 71117 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
266817 switch(ndir)
6494 {
6495 case 8:
6496 case up:
6497 53728 break;
6498
6499 case 12:
6500 case down:
6501 54633 tile+=2;
6502 54633 break;
6503
6504 case 14:
6505 case left:
6506 67625 tile+=4;
6507 67625 break;
6508
6509 case 10:
6510 case right:
6511 71117 tile+=6;
6512 71117 break;
6513
6514 case 9:
6515 case r_up:
6516
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6517 5706 break;
6518
6519 tile+=10;
6520 break;
6521
6522 case 11:
6523 case r_down:
6524
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6525 5154 tile+=2;
6526 else
6527 tile+=14;
6528
6529 5154 break;
6530
6531 case 13:
6532 case l_down:
6533
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6534 4872 tile+=2;
6535 else
6536 tile+=12;
6537
6538 4872 break;
6539
6540 case 15:
6541 case l_up:
6542
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6543 3982 break;
6544
6545 tile+=8;
6546 break;
6547
6548 default:
6549 //dir=(zc_oldrand()*100)%8;
6550 //tiledir_small(dir);
6551 // flip=zc_oldrand()&3;
6552 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6553 break;
6554 }
6555 266817 }
6556
6557 11660468 void enemy::tiledir(int32_t ndir, bool fourdir)
6558 {
6559
1/2
✓ Branch 0 taken 11660468 times.
✗ Branch 1 not taken.
11660468 if ( !do_animation ) return;
6560 11660468 flip=0;
6561
6562
9/9
✓ Branch 0 taken 2359939 times.
✓ Branch 1 taken 2044242 times.
✓ Branch 2 taken 2781916 times.
✓ Branch 3 taken 2670926 times.
✓ Branch 4 taken 406885 times.
✓ Branch 5 taken 486841 times.
✓ Branch 6 taken 474500 times.
✓ Branch 7 taken 419015 times.
✓ Branch 8 taken 16204 times.
11660468 switch(ndir)
6563 {
6564 case 8:
6565 case up:
6566 2359939 break;
6567
6568 case 12:
6569 case down:
6570 2044242 tile+=4;
6571 2044242 break;
6572
6573 case 14:
6574 case left:
6575 2781916 tile+=8;
6576 2781916 break;
6577
6578 case 10:
6579 case right:
6580 2670926 tile+=12;
6581 2670926 break;
6582
6583 case 9:
6584 case r_up:
6585
2/2
✓ Branch 0 taken 57693 times.
✓ Branch 1 taken 349192 times.
406885 if(fourdir)
6586 57693 break;
6587 else
6588 349192 tile+=24;
6589
6590 349192 break;
6591
6592 case 11:
6593 case r_down:
6594
2/2
✓ Branch 0 taken 63504 times.
✓ Branch 1 taken 423337 times.
486841 if(fourdir)
6595 63504 tile+=4;
6596 else
6597 423337 tile+=32;
6598
6599 486841 break;
6600
6601 case 13:
6602 case l_down:
6603
2/2
✓ Branch 0 taken 66073 times.
✓ Branch 1 taken 408427 times.
474500 if(fourdir)
6604 66073 tile+=4;
6605 else
6606 408427 tile+=28;
6607
6608 474500 break;
6609
6610 case 15:
6611 case l_up:
6612
2/2
✓ Branch 0 taken 50160 times.
✓ Branch 1 taken 368855 times.
419015 if(fourdir)
6613 50160 break;
6614 else
6615 368855 tile+=20;
6616
6617 368855 break;
6618
6619 default:
6620 //dir=(zc_oldrand()*100)%8;
6621 //tiledir(dir);
6622 // flip=zc_oldrand()&3;
6623 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6624 16204 break;
6625 }
6626 11660468 }
6627
6628 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6629 {
6630
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
6631 3868 flip=0;
6632
6633
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6634 {
6635 case 8:
6636 case up:
6637 297 break;
6638
6639 case 12:
6640 case down:
6641 tile+=8;
6642 break;
6643
6644 case 14:
6645 case left:
6646 195 tile+=40;
6647 195 break;
6648
6649 case 10:
6650 case right:
6651 179 tile+=48;
6652 179 break;
6653
6654 case 9:
6655 case r_up:
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6657 break;
6658
6659 306 tile+=88;
6660 306 break;
6661
6662 case 11:
6663 case r_down:
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6665 tile+=8;
6666 else
6667 1235 tile+=128;
6668
6669 1235 break;
6670
6671 case 13:
6672 case l_down:
6673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6674 tile+=8;
6675 else
6676 1324 tile+=120;
6677
6678 1324 break;
6679
6680 case 15:
6681 case l_up:
6682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6683 break;
6684
6685 332 tile+=80;
6686 332 break;
6687
6688 default:
6689 //dir=(zc_oldrand()*100)%8;
6690 //tiledir_big(dir);
6691 // flip=zc_oldrand()&3;
6692 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6693 break;
6694 }
6695 3868 }
6696
6697 22905054 void enemy::update_enemy_frame()
6698 {
6699
3/4
✓ Branch 0 taken 22904912 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22904912 times.
22905054 if(fallclk||drownclk) return;
6700
1/2
✓ Branch 0 taken 22904912 times.
✗ Branch 1 not taken.
22904912 if (!do_animation)
6701 return;
6702
6703
3/4
✓ Branch 0 taken 153758 times.
✓ Branch 1 taken 22751154 times.
✓ Branch 2 taken 153758 times.
✗ Branch 3 not taken.
22904912 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6704
6705
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22904912 if(get_qr(qr_ANONE_NOANIM)
6706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22904912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22904912 && anim == aNONE && family != eeGUY)
6707 return;
6708
2/2
✓ Branch 0 taken 45769 times.
✓ Branch 1 taken 22859143 times.
22904912 int32_t newfrate = zc_max(frate,4);
6709 22904912 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6710 22904912 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6711
2/2
✓ Branch 0 taken 15606509 times.
✓ Branch 1 taken 7298403 times.
22904912 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6712 22904912 tile = o_tile;
6713 22904912 int32_t basetile = o_tile;
6714 22904912 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6715 22904912 bool ignore_extend = false;
6716
34/40
✓ Branch 0 taken 164903 times.
✓ Branch 1 taken 5459 times.
✓ Branch 2 taken 38520 times.
✓ Branch 3 taken 1313148 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89141 times.
✓ Branch 7 taken 233641 times.
✓ Branch 8 taken 128056 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2773771 times.
✓ Branch 12 taken 41139 times.
✓ Branch 13 taken 50626 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 353574 times.
✓ Branch 16 taken 622431 times.
✓ Branch 17 taken 163042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 98223 times.
✓ Branch 20 taken 157529 times.
✓ Branch 21 taken 428287 times.
✓ Branch 22 taken 1050207 times.
✓ Branch 23 taken 934304 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 266817 times.
✓ Branch 26 taken 2408805 times.
✓ Branch 27 taken 3857795 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 399313 times.
✓ Branch 30 taken 912736 times.
✓ Branch 31 taken 614651 times.
✓ Branch 32 taken 161932 times.
✓ Branch 33 taken 1317852 times.
✓ Branch 34 taken 74670 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3483844 times.
✓ Branch 37 taken 281552 times.
✓ Branch 38 taken 219227 times.
✓ Branch 39 taken 38974 times.
22904912 switch(anim)
6717 {
6718
6719 case aDONGO:
6720 {
6721 41139 int32_t fr = stunclk>0 ? 16 : 8;
6722
6723
6/6
✓ Branch 0 taken 39717 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 4800 times.
✓ Branch 3 taken 34917 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 3200 times.
41139 if(!dying && clk2>0 && clk2<=64)
6724 {
6725 // bloated
6726
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 448 times.
✓ Branch 3 taken 1152 times.
✓ Branch 4 taken 768 times.
3200 switch(dir)
6727 {
6728 case up:
6729 832 tile+=9;
6730 832 flip=0;
6731 832 xofs=0;
6732 832 dummy_int[1]=0; //no additional tiles
6733 832 break;
6734
6735 case down:
6736 448 tile+=7;
6737 448 flip=0;
6738 448 xofs=0;
6739 448 dummy_int[1]=0; //no additional tiles
6740 448 break;
6741
6742 case left:
6743 1152 flip=1;
6744 1152 tile+=4;
6745 1152 xofs=16;
6746 1152 dummy_int[1]=1; //second tile is next tile
6747 1152 break;
6748
6749 case right:
6750 768 flip=0;
6751 768 tile+=5;
6752 768 xofs=16;
6753 768 dummy_int[1]=-1; //second tile is previous tile
6754 768 break;
6755 }
6756 3200 }
6757
4/4
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 36517 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 783 times.
37939 else if(!dying || clk2>19)
6758 {
6759 // normal
6760
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7974 times.
✓ Branch 2 taken 8400 times.
✓ Branch 3 taken 12214 times.
✓ Branch 4 taken 8568 times.
37156 switch(dir)
6761 {
6762 case up:
6763 7974 tile+=8;
6764 7974 flip=(clk&fr)?1:0;
6765 7974 xofs=0;
6766 7974 dummy_int[1]=0; //no additional tiles
6767 7974 break;
6768
6769 case down:
6770 8400 tile+=6;
6771 8400 flip=(clk&fr)?1:0;
6772 8400 xofs=0;
6773 8400 dummy_int[1]=0; //no additional tiles
6774 8400 break;
6775
6776 case left:
6777 12214 flip=1;
6778 12214 tile+=(clk&fr)?2:0;
6779 12214 xofs=16;
6780 12214 dummy_int[1]=1; //second tile is next tile
6781 12214 break;
6782
6783 case right:
6784 8568 flip=0;
6785 8568 tile+=(clk&fr)?3:1;
6786 8568 xofs=16;
6787 8568 dummy_int[1]=-1; //second tile is next tile
6788 8568 break;
6789 }
6790 37156 }
6791 }
6792 41139 break;
6793
6794 case aNEWDONGO:
6795 {
6796 50626 int32_t fr4=0;
6797
6798
6/6
✓ Branch 0 taken 48878 times.
✓ Branch 1 taken 1748 times.
✓ Branch 2 taken 3936 times.
✓ Branch 3 taken 44942 times.
✓ Branch 4 taken 1312 times.
✓ Branch 5 taken 2624 times.
50626 if(!dying && clk2>0 && clk2<=64)
6799 {
6800 // bloated
6801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 if(clk2>=0)
6802 {
6803 2624 fr4=3;
6804 2624 }
6805
6806
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 2009 times.
2624 if(clk2>=16)
6807 {
6808 2009 fr4=2;
6809 2009 }
6810
6811
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 1353 times.
2624 if(clk2>=32)
6812 {
6813 1353 fr4=1;
6814 1353 }
6815
6816
2/2
✓ Branch 0 taken 1927 times.
✓ Branch 1 taken 697 times.
2624 if(clk2>=48)
6817 {
6818 697 fr4=0;
6819 697 }
6820
6821
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1088 times.
2624 switch(dir)
6822 {
6823 case up:
6824 256 xofs=0;
6825 256 tile+=8+fr4;
6826 256 dummy_int[1]=0; //no additional tiles
6827 256 break;
6828
6829 case down:
6830 576 xofs=0;
6831 576 tile+=12+fr4;
6832 576 dummy_int[1]=0; //no additional tiles
6833 576 break;
6834
6835 case left:
6836 704 tile+=29+(2*fr4);
6837 704 xofs=16;
6838 704 dummy_int[1]=-1; //second tile is previous tile
6839 704 break;
6840
6841 case right:
6842 1088 tile+=49+(2*fr4);
6843 1088 xofs=16;
6844 1088 dummy_int[1]=-1; //second tile is previous tile
6845 1088 break;
6846 }
6847 2624 }
6848
4/4
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 46254 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 825 times.
48002 else if(!dying || clk2>19)
6849 {
6850 // normal
6851
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9019 times.
✓ Branch 2 taken 9429 times.
✓ Branch 3 taken 14024 times.
✓ Branch 4 taken 14705 times.
47177 switch(dir)
6852 {
6853 case up:
6854 9019 xofs=0;
6855 9019 tile+=((clk&12)>>2);
6856 9019 dummy_int[1]=0; //no additional tiles
6857 9019 break;
6858
6859 case down:
6860 9429 xofs=0;
6861 9429 tile+=4+((clk&12)>>2);
6862 9429 dummy_int[1]=0; //no additional tiles
6863 9429 break;
6864
6865 case left:
6866 14024 tile+=21+((clk&12)>>1);
6867 14024 xofs=16;
6868 14024 dummy_int[1]=-1; //second tile is previous tile
6869 14024 break;
6870
6871 case right:
6872 14705 flip=0;
6873 14705 tile+=41+((clk&12)>>1);
6874 14705 xofs=16;
6875 14705 dummy_int[1]=-1; //second tile is previous tile
6876 14705 break;
6877 }
6878 47177 }
6879 }
6880 50626 break;
6881
6882 case aDONGOBS:
6883 {
6884 818 int32_t fr4=0;
6885
6886
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
6887 {
6888 // bloated
6889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
6890 {
6891 128 fr4=3;
6892 128 }
6893
6894
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
6895 {
6896 98 fr4=2;
6897 98 }
6898
6899
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
6900 {
6901 66 fr4=1;
6902 66 }
6903
6904
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
6905 {
6906 34 fr4=0;
6907 34 }
6908
6909
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
6910 {
6911 case up:
6912 tile+=28+fr4;
6913 yofs+=8;
6914 dummy_int[1]=-20; //second tile change
6915 dummy_int[2]=0; //new xofs change
6916 dummy_int[3]=-16; //new xofs change
6917 break;
6918
6919 case down:
6920 tile+=12+fr4;
6921 yofs-=8;
6922 dummy_int[1]=20; //second tile change
6923 dummy_int[2]=0; //new xofs change
6924 dummy_int[3]=16; //new xofs change
6925 break;
6926
6927 case left:
6928 128 tile+=49+(2*fr4);
6929 128 xofs+=8;
6930 128 dummy_int[1]=-1; //second tile change
6931 128 dummy_int[2]=-16; //new xofs change
6932 128 dummy_int[3]=0; //new xofs change
6933 128 break;
6934
6935 case right:
6936 tile+=69+(2*fr4);
6937 xofs+=8;
6938 dummy_int[1]=-1; //second tile change
6939 dummy_int[2]=-16; //new xofs change
6940 dummy_int[3]=0; //new xofs change
6941 break;
6942 }
6943 128 }
6944
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
6945 {
6946 // normal
6947
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
6948 {
6949 case up:
6950 96 tile+=20+((clk&24)>>3);
6951 96 yofs+=8;
6952 96 dummy_int[1]=-20; //second tile change
6953 96 dummy_int[2]=0; //new xofs change
6954 96 dummy_int[3]=-16; //new xofs change
6955 96 break;
6956
6957 case down:
6958 129 tile+=4+((clk&24)>>3);
6959 129 yofs-=8;
6960 129 dummy_int[1]=20; //second tile change
6961 129 dummy_int[2]=0; //new xofs change
6962 129 dummy_int[3]=16; //new xofs change
6963 129 break;
6964
6965 case left:
6966 332 xofs=-8;
6967 332 tile+=40+((clk&24)>>2);
6968 332 dummy_int[1]=1; //second tile change
6969 332 dummy_int[2]=16; //new xofs change
6970 332 dummy_int[3]=0; //new xofs change
6971 332 break;
6972
6973 case right:
6974 97 tile+=60+((clk&24)>>2);
6975 97 xofs=-8;
6976 97 dummy_int[1]=1; //second tile change
6977 97 dummy_int[2]=16; //new xofs change
6978 97 dummy_int[3]=0; //new xofs change
6979 97 break;
6980 }
6981 654 }
6982 }
6983 818 break;
6984
6985 case aWIZZ:
6986 {
6987 // if(d->misc1)
6988
2/2
✓ Branch 0 taken 139048 times.
✓ Branch 1 taken 214526 times.
353574 if(dmisc1)
6989 {
6990
2/2
✓ Branch 0 taken 69275 times.
✓ Branch 1 taken 69773 times.
139048 if(clk&8)
6991 {
6992 69773 ++tile;
6993 69773 }
6994 139048 }
6995 else
6996 {
6997
2/2
✓ Branch 0 taken 107350 times.
✓ Branch 1 taken 107176 times.
214526 if(frame&4)
6998 {
6999 107176 ++tile;
7000 107176 }
7001 }
7002
7003
4/4
✓ Branch 0 taken 55328 times.
✓ Branch 1 taken 124116 times.
✓ Branch 2 taken 114795 times.
✓ Branch 3 taken 59335 times.
353574 switch(dir)
7004 {
7005 case 9:
7006 case 15:
7007 case up:
7008 55328 tile+=2;
7009 55328 break;
7010
7011 case down:
7012 59335 break;
7013
7014 case 13:
7015 case left:
7016 124116 flip=1;
7017 124116 break;
7018
7019 default:
7020 114795 flip=0;
7021 114795 break;
7022 }
7023 }
7024 353574 break;
7025
7026 case aNEWWIZZ:
7027 {
7028 622431 tiledir(dir,true);
7029
7030 // if(d->misc1) //walking wizzrobe
7031
2/2
✓ Branch 0 taken 330881 times.
✓ Branch 1 taken 291550 times.
622431 if(dmisc1) //walking wizzrobe
7032 {
7033
2/2
✓ Branch 0 taken 166270 times.
✓ Branch 1 taken 164611 times.
330881 if(clk&8)
7034 {
7035 164611 tile+=2;
7036 164611 }
7037
7038
2/2
✓ Branch 0 taken 165827 times.
✓ Branch 1 taken 165054 times.
330881 if(clk&4)
7039 {
7040 165054 tile+=1;
7041 165054 }
7042
7043
2/4
✓ Branch 0 taken 330881 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 330881 times.
330881 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7044 {
7045
2/2
✓ Branch 0 taken 296297 times.
✓ Branch 1 taken 34584 times.
330881 if(dummy_int[1]>0)
7046 {
7047 34584 tile+=40;
7048 34584 }
7049 330881 }
7050 330881 }
7051 else
7052 {
7053
4/4
✓ Branch 0 taken 267218 times.
✓ Branch 1 taken 24332 times.
✓ Branch 2 taken 62854 times.
✓ Branch 3 taken 204364 times.
291550 if(dummy_bool[1]||dummy_bool[2])
7054 {
7055 87186 tile+=20;
7056
7057
2/2
✓ Branch 0 taken 24332 times.
✓ Branch 1 taken 62854 times.
87186 if(dummy_bool[2])
7058 {
7059 62854 tile+=20;
7060 62854 }
7061 87186 }
7062
7063 291550 tile+=((frame>>1)&3);
7064 }
7065 }
7066 622431 break;
7067
7068 case a3FRM:
7069 {
7070
2/2
✓ Branch 0 taken 38762 times.
✓ Branch 1 taken 124280 times.
163042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7071 }
7072 163042 break;
7073
7074 case a3FRM4DIR:
7075 {
7076 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7077 }
7078 break;
7079
7080 case aVIRE:
7081 {
7082
2/2
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 22222 times.
98223 if(dir==up)
7083 {
7084 22222 tile+=2;
7085 22222 }
7086
7087 98223 tile+=fx;
7088 }
7089 98223 break;
7090
7091 case aROPE:
7092 {
7093 164903 tile+=(1-fx);
7094 164903 flip = dir==left ? 1:0;
7095 }
7096 164903 break;
7097
7098 case aZORA:
7099 {
7100 int32_t dl;
7101
7102
2/2
✓ Branch 0 taken 33018 times.
✓ Branch 1 taken 124511 times.
157529 if(clk<36)
7103 {
7104 33018 dl=clk+5;
7105 33018 goto waves2;
7106 }
7107
7108
2/2
✓ Branch 0 taken 58613 times.
✓ Branch 1 taken 65898 times.
124511 if(clk<36+66)
7109
2/2
✓ Branch 0 taken 33479 times.
✓ Branch 1 taken 25134 times.
58613 tile=(dir==up)?o_tile+1:o_tile;
7110 else
7111 {
7112 65898 dl=clk-36-66;
7113 waves2:
7114 98916 tile=((dl/11)&1)+s_tile;
7115 98916 basetile = s_tile;
7116 }
7117 }
7118 157529 break;
7119
7120 case aNEWZORA:
7121 {
7122 428287 f4=(clk/16)%4;
7123
7124 428287 tiledir(dir,true);
7125 int32_t dl;
7126
7127
4/4
✓ Branch 0 taken 304957 times.
✓ Branch 1 taken 123330 times.
✓ Branch 2 taken 159809 times.
✓ Branch 3 taken 145148 times.
428287 if((clk>35)&&(clk<36+67)) //surfaced
7128 {
7129
4/4
✓ Branch 0 taken 123977 times.
✓ Branch 1 taken 21171 times.
✓ Branch 2 taken 17680 times.
✓ Branch 3 taken 106297 times.
145148 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7130 {
7131 106297 tile+=80;
7132 106297 } //mouth closed
7133 else
7134 {
7135 38851 tile+=40;
7136 }
7137
7138 145148 tile+=f4;
7139 145148 }
7140 else
7141 {
7142
2/2
✓ Branch 0 taken 123330 times.
✓ Branch 1 taken 159809 times.
283139 if(clk<36)
7143 {
7144 123330 dl=clk+5;
7145 123330 }
7146 else
7147 {
7148 159809 dl=clk-36-66;
7149 }
7150
7151 283139 tile+=((dl/5)&3);
7152 }
7153 }
7154 428287 break;
7155
7156 case a4FRM4EYE:
7157 case a2FRM4EYE:
7158 case a4FRM8EYE:
7159 case a4FRM8EYEB: //big version
7160 case a4FRM4EYEB:
7161 {
7162 128056 tilerows = 2;
7163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakex = x + 8*(zc_max(1,txsz)-1);
7164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakey = y + 8*(zc_max(1,tysz)-1);
7165 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7166 128056 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7167 128056 int32_t lookat=zc_oldrand()&15;
7168
7169
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 87102 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
128056 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7170 {
7171 20770 lookat=l_down;
7172 20770 }
7173
4/4
✓ Branch 0 taken 41196 times.
✓ Branch 1 taken 66090 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 21012 times.
107286 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7174 {
7175 21012 lookat=down;
7176 21012 }
7177
4/4
✓ Branch 0 taken 33446 times.
✓ Branch 1 taken 52828 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13262 times.
86274 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7178 {
7179 13262 lookat=r_down;
7180 13262 }
7181
4/4
✓ Branch 0 taken 32038 times.
✓ Branch 1 taken 40974 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11854 times.
73012 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7182 {
7183 11854 lookat=right;
7184 11854 }
7185
4/4
✓ Branch 0 taken 25060 times.
✓ Branch 1 taken 36098 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4876 times.
61158 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7186 {
7187 4876 lookat=r_up;
7188 4876 }
7189
4/4
✓ Branch 0 taken 26018 times.
✓ Branch 1 taken 30264 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5834 times.
56282 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7190 {
7191 5834 lookat=up;
7192 5834 }
7193
4/4
✓ Branch 0 taken 30200 times.
✓ Branch 1 taken 20248 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 10016 times.
50448 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7194 {
7195 10016 lookat=l_up;
7196 10016 }
7197 else
7198 {
7199 40432 lookat=left;
7200 }
7201
7202 128056 int32_t dir2 = dir;
7203 128056 dir = lookat;
7204
3/6
✓ Branch 0 taken 128056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128056 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128056 times.
128056 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7205 else
7206 {
7207 tiledir_big(dir,(anim == a4FRM4EYEB));
7208 tile+=2*f4;
7209 ignore_extend = true;
7210 }
7211 128056 dir = dir2;
7212 }
7213 128056 break;
7214
7215 case aFLIP:
7216 {
7217 1050207 flip = f2&1;
7218 }
7219 1050207 break;
7220
7221 case a2FRM:
7222 {
7223 934304 tile += (1-f2);
7224 }
7225 934304 break;
7226
7227 case a2FRMB:
7228 {
7229 tile+= 2*(1-f2);
7230 ignore_extend = true;
7231 }
7232 break;
7233
7234 case a2FRM4DIR:
7235 {
7236 266817 basetile = n_frame_n_dir(2, 4, f2&1);
7237 }
7238 266817 break;
7239
7240 case a4FRM4DIRF:
7241 {
7242 2408805 basetile = n_frame_n_dir(4,4,f4);
7243
7244
2/2
✓ Branch 0 taken 1574669 times.
✓ Branch 1 taken 834136 times.
2408805 if(clk2>0) //stopped to fire
7245 {
7246 834136 tile+=20;
7247
7248
2/2
✓ Branch 0 taken 413682 times.
✓ Branch 1 taken 420454 times.
834136 if(clk2<17) //firing
7249 {
7250 420454 tile+=20;
7251 420454 }
7252 834136 }
7253 }
7254 2408805 break;
7255
7256 case a4FRM4DIR:
7257 {
7258 3857795 basetile = n_frame_n_dir(4,4,f4);
7259 }
7260 3857795 break;
7261
7262 case a4FRM8DIRF:
7263 {
7264 tilerows = 2;
7265 basetile = n_frame_n_dir(4,8,f4);
7266
7267 if(clk2>0) //stopped to fire
7268 {
7269 tile+=40;
7270
7271 if(clk2<17) //firing
7272 {
7273 tile+=40;
7274 }
7275 }
7276 }
7277 break;
7278
7279 case a4FRM8DIRB:
7280 case a4FRM8DIRFB:
7281 {
7282 3868 tilerows = 2;
7283 3868 tiledir_big(dir,false);
7284 3868 tile+=2*f4;
7285
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7286 {
7287 tile+=80;
7288
7289 if(clk2<17) //firing
7290 {
7291 tile+=80;
7292 }
7293 }
7294 3868 ignore_extend = true;
7295 }
7296 3868 break;
7297
7298 case a4FRM4DIRB:
7299 case a4FRM4DIRFB:
7300 {
7301 tilerows = 2;
7302 tiledir_big(dir,true);
7303 tile+=2*f4;
7304 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7305 {
7306 tile+=40;
7307
7308 if(clk2<17) //firing
7309 {
7310 tile+=40;
7311 }
7312 }
7313 ignore_extend = true;
7314 }
7315 break;
7316
7317 case aOCTO:
7318 {
7319
5/5
✓ Branch 0 taken 2913 times.
✓ Branch 1 taken 85458 times.
✓ Branch 2 taken 96229 times.
✓ Branch 3 taken 112826 times.
✓ Branch 4 taken 101887 times.
399313 switch(dir)
7320 {
7321 case up:
7322 85458 flip = 2;
7323 85458 break;
7324
7325 case down:
7326 96229 flip = 0;
7327 96229 break;
7328
7329 case left:
7330 112826 flip = 0;
7331 112826 tile += 2;
7332 112826 break;
7333
7334 case right:
7335 101887 flip = 1;
7336 101887 tile += 2;
7337 101887 break;
7338 }
7339
7340 399313 tile+=f2;
7341 }
7342 399313 break;
7343
7344 case aWALK:
7345 {
7346
5/5
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 187339 times.
✓ Branch 2 taken 207694 times.
✓ Branch 3 taken 256906 times.
✓ Branch 4 taken 256215 times.
912736 switch(dir)
7347 {
7348 case up:
7349 187339 tile+=3;
7350 187339 flip = f2;
7351 187339 break;
7352
7353 case down:
7354 207694 tile+=2;
7355 207694 flip = f2;
7356 207694 break;
7357
7358 case left:
7359 256906 flip=1;
7360 256906 tile += f2;
7361 256906 break;
7362
7363 case right:
7364 256215 flip=0;
7365 256215 tile += f2;
7366 256215 break;
7367 }
7368 }
7369 912736 break;
7370
7371 case aDWALK:
7372 {
7373
3/4
✓ Branch 0 taken 81208 times.
✓ Branch 1 taken 533443 times.
✓ Branch 2 taken 81208 times.
✗ Branch 3 not taken.
614651 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7374 {
7375 tile=s_tile;
7376 basetile = s_tile;
7377 }
7378
7379
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129268 times.
✓ Branch 2 taken 133261 times.
✓ Branch 3 taken 177242 times.
✓ Branch 4 taken 174880 times.
614651 switch(dir)
7380 {
7381 case up:
7382 129268 tile+=2;
7383 129268 flip=f2;
7384 129268 break;
7385
7386 case down:
7387 133261 flip=0;
7388 133261 tile+=(1-f2);
7389 133261 break;
7390
7391 case left:
7392 177242 flip=1;
7393 177242 tile+=(3+f2);
7394 177242 break;
7395
7396 case right:
7397 174880 flip=0;
7398 174880 tile+=(3+f2);
7399 174880 break;
7400 }
7401 }
7402 614651 break;
7403
7404 case aTEK:
7405 {
7406
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 60556 times.
161932 if(misc==0)
7407 {
7408 60556 tile += f2;
7409 60556 }
7410
2/2
✓ Branch 0 taken 53958 times.
✓ Branch 1 taken 47418 times.
101376 else if(misc!=1)
7411 {
7412 47418 ++tile;
7413 47418 }
7414 }
7415 161932 break;
7416
7417 case aNEWTEK:
7418 {
7419
2/2
✓ Branch 0 taken 329922 times.
✓ Branch 1 taken 987930 times.
1317852 if(step<0) //up
7420 {
7421
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 162358 times.
✓ Branch 2 taken 167564 times.
329922 switch(clk3)
7422 {
7423 case left:
7424 162358 flip=0;
7425 162358 tile+=20;
7426 162358 break;
7427
7428 case right:
7429 167564 flip=0;
7430 167564 tile+=24;
7431 167564 break;
7432 }
7433 329922 }
7434
2/2
✓ Branch 0 taken 42115 times.
✓ Branch 1 taken 945815 times.
987930 else if(step==0)
7435 {
7436
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31831 times.
✓ Branch 2 taken 10284 times.
42115 switch(clk3)
7437 {
7438 case left:
7439 31831 flip=0;
7440 31831 tile+=8;
7441 31831 break;
7442
7443 case right:
7444 10284 flip=0;
7445 10284 tile+=12;
7446 10284 break;
7447 }
7448 42115 } //down
7449 else
7450 {
7451
3/3
✓ Branch 0 taken 64726 times.
✓ Branch 1 taken 445156 times.
✓ Branch 2 taken 435933 times.
945815 switch(clk3)
7452 {
7453 case left:
7454 445156 flip=0;
7455 445156 tile+=28;
7456 445156 break;
7457
7458 case right:
7459 435933 flip=0;
7460 435933 tile+=32;
7461 435933 break;
7462 }
7463 }
7464
7465
2/2
✓ Branch 0 taken 845637 times.
✓ Branch 1 taken 472215 times.
1317852 if(misc==0)
7466 {
7467 472215 tile+=f4;
7468 472215 }
7469
2/2
✓ Branch 0 taken 408849 times.
✓ Branch 1 taken 436788 times.
845637 else if(misc!=1)
7470 {
7471 436788 tile+=2;
7472 436788 }
7473 }
7474 1317852 break;
7475
7476 case aARMOS:
7477 {
7478
2/2
✓ Branch 0 taken 2153 times.
✓ Branch 1 taken 3306 times.
5459 if(!fading)
7479 {
7480 3306 tile += fx;
7481
7482
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 847 times.
3306 if(dir==up)
7483 847 tile += 2;
7484 3306 }
7485 }
7486 5459 break;
7487
7488 case aARMOS4:
7489 {
7490
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6349 times.
✓ Branch 2 taken 13276 times.
✓ Branch 3 taken 9550 times.
✓ Branch 4 taken 9345 times.
38520 switch(dir)
7491 {
7492 case up:
7493 6349 flip=0;
7494 6349 break;
7495
7496 case down:
7497 13276 flip=0;
7498 13276 tile+=4;
7499 13276 break;
7500
7501 case left:
7502 9550 flip=0;
7503 9550 tile+=8;
7504 9550 break;
7505
7506 case right:
7507 9345 flip=0;
7508 9345 tile+=12;
7509 9345 break;
7510 }
7511
7512
2/2
✓ Branch 0 taken 7161 times.
✓ Branch 1 taken 31359 times.
38520 if(!fading)
7513 {
7514 31359 tile+=f4;
7515 31359 }
7516 }
7517 38520 break;
7518
7519 case aGHINI:
7520 {
7521
4/4
✓ Branch 0 taken 14931 times.
✓ Branch 1 taken 18961 times.
✓ Branch 2 taken 40404 times.
✓ Branch 3 taken 374 times.
74670 switch(dir)
7522 {
7523 case 8:
7524 case 9:
7525 case up:
7526 14931 ++tile;
7527 14931 flip=0;
7528 14931 break;
7529
7530 case 15:
7531 374 ++tile;
7532 374 flip=1;
7533 374 break;
7534
7535 case 10:
7536 case 11:
7537 case right:
7538 18961 flip=1;
7539 18961 break;
7540
7541 default:
7542 40404 flip=0;
7543 40404 break;
7544 }
7545 }
7546 74670 break;
7547
7548 case a2FRMPOS:
7549 {
7550 1313148 tile+=posframe;
7551 }
7552 1313148 break;
7553
7554 case a4FRMPOS4DIR:
7555 {
7556 216057 basetile = n_frame_n_dir(4,4,0);
7557 // tile+=f2;
7558 216057 tile+=posframe;
7559 }
7560 216057 break;
7561
7562 case a4FRMPOS4DIRF:
7563 {
7564 basetile = n_frame_n_dir(4,4,0);
7565
7566 if(clk2>0) //stopped to fire
7567 {
7568 tile+=20;
7569
7570 if(clk2<17) //firing
7571 {
7572 tile+=20;
7573 }
7574 }
7575
7576 // tile+=f2;
7577 tile+=posframe;
7578 }
7579 break;
7580
7581 case a4FRMPOS8DIR:
7582 {
7583 3483844 tilerows = 2;
7584 3483844 int32_t n = tile;
7585 3483844 basetile = n_frame_n_dir(4,8,0);
7586 // tile+=f2;
7587 3483844 tile+=posframe;
7588 }
7589 3483844 break;
7590
7591 case a4FRMPOS8DIRF:
7592 {
7593 tilerows = 2;
7594 basetile = n_frame_n_dir(4,8,0);
7595
7596 if(clk2>0) //stopped to fire
7597 {
7598 tile+=40;
7599
7600 if(clk2<17) //firing
7601 {
7602 tile+=40;
7603 }
7604 }
7605
7606 tile+=posframe;
7607 }
7608 break;
7609
7610 case aNEWLEV:
7611 {
7612 281552 tiledir(dir,true);
7613
7614
4/5
✓ Branch 0 taken 92775 times.
✓ Branch 1 taken 45501 times.
✓ Branch 2 taken 18315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124961 times.
281552 switch(misc)
7615 {
7616 case -1:
7617 case 0:
7618 92775 return;
7619
7620 case 1:
7621
7622 // case 5: cs = d->misc2; break;
7623 case 5:
7624 45501 cs = dmisc2;
7625 45501 break;
7626
7627 case 2:
7628 case 4:
7629 18315 tile += 20;
7630 18315 break;
7631
7632 case 3:
7633 124961 tile += 40;
7634 124961 break;
7635 }
7636
7637 188777 tile+=f4;
7638 }
7639 188777 break;
7640
7641 case aLEV:
7642 {
7643 219227 f4 = ((clk/5)&1);
7644
7645
4/5
✓ Branch 0 taken 106859 times.
✓ Branch 1 taken 24845 times.
✓ Branch 2 taken 11238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76285 times.
219227 switch(misc)
7646 {
7647 case -1:
7648 case 0:
7649 106859 return;
7650
7651 case 1:
7652
7653 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7654 case 5:
7655 24845 tile += (f2) ? 1 : 0;
7656 24845 cs = dmisc2;
7657 24845 break;
7658
7659 case 2:
7660 case 4:
7661 11238 tile += 2;
7662 11238 break;
7663
7664 case 3:
7665 76285 tile += (f4) ? 4 : 3;
7666 76285 break;
7667 }
7668 }
7669 112368 break;
7670
7671 case aWALLM:
7672 {
7673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89141 times.
89141 if(!dummy_bool[1])
7674 {
7675 89141 tile += f2;
7676 89141 }
7677 }
7678 89141 break;
7679
7680 case aNEWWALLM:
7681 {
7682 233641 int32_t tempdir=0;
7683
7684
4/4
✓ Branch 0 taken 30389 times.
✓ Branch 1 taken 24290 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 172241 times.
233641 switch(misc)
7685 {
7686 case 1:
7687 case 2:
7688 24290 tempdir=clk3;
7689 24290 break;
7690
7691 case 3:
7692 case 4:
7693 case 5:
7694 30389 tempdir=dir;
7695 30389 break;
7696
7697 case 6:
7698 case 7:
7699 6721 tempdir=clk3^1;
7700 6721 break;
7701 }
7702
7703 233641 tiledir(tempdir,true);
7704
7705
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 233063 times.
233641 if(!dummy_bool[1])
7706 {
7707 233063 tile+=f4;
7708 233063 }
7709 }
7710 233641 break;
7711
7712 case a4FRMNODIR:
7713 {
7714 38974 tile+=f4;
7715 }
7716 38974 break;
7717
7718 } // switch(d->anim)
7719
7720 // flashing
7721 // if(d->flags2 & guy_flashing)
7722
2/2
✓ Branch 0 taken 22180744 times.
✓ Branch 1 taken 524534 times.
22705278 if(flags2 & guy_flashing)
7723 {
7724 524534 cs = (frame&3) + 6;
7725 524534 }
7726
7727
2/2
✓ Branch 0 taken 22673164 times.
✓ Branch 1 taken 32114 times.
22705278 if(flags2&guy_transparent)
7728 {
7729 32114 drawstyle=1;
7730 32114 }
7731
7732 22705278 int32_t change = tile-basetile;
7733
7734
3/6
✓ Branch 0 taken 1174288 times.
✓ Branch 1 taken 21530990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1174288 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22705278 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7735 {
7736
2/2
✓ Branch 0 taken 953842 times.
✓ Branch 1 taken 220446 times.
1174288 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7737 {
7738 953842 tile=basetile+txsz*change;
7739 953842 }
7740 else
7741 {
7742 220446 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7743 }
7744 1174288 }
7745 else
7746 {
7747 21530990 tile=basetile+change;
7748 }
7749 22905054 }
7750
7751 53882 int32_t wpnsfx(int32_t wpn)
7752 {
7753
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17500 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 18023 times.
✓ Branch 4 taken 11644 times.
✓ Branch 5 taken 6432 times.
53882 switch(wpn)
7754 {
7755 case ewFireTrail:
7756 case ewFlame:
7757 case ewFlame2Trail:
7758 case ewFlame2:
7759 17500 return WAV_FIRE;
7760
7761 case ewWind:
7762 case ewMagic:
7763 283 return WAV_WAND;
7764
7765 case ewIce:
7766 return WAV_ZN1ICE;
7767
7768 case ewRock:
7769
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 6168 times.
6432 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7770 6168 break;
7771
7772 case ewFireball2:
7773 case ewFireball:
7774
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 18016 times.
18023 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7775 18016 }
7776
7777 35828 return -1;
7778 53882 }
7779
7780 42799961 int32_t enemy::run_script(int32_t mode)
7781 {
7782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42799961 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7783
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42799961 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7784 42799961 return RUNSCRIPT_OK;
7785 int32_t ret = RUNSCRIPT_OK;
7786 alloc_scriptmem();
7787 switch(mode)
7788 {
7789 case MODE_NORMAL:
7790 return ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7791 case MODE_WAITDRAW:
7792 if(waitdraw)
7793 {
7794 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7795 waitdraw = 0;
7796 }
7797 break;
7798 }
7799 return ret;
7800 42799961 }
7801 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7802 {
7803 return al_map_rgba(255,0,0,opacity);
7804 }
7805 /********************************/
7806 /********* Guy Class **********/
7807 /********************************/
7808
7809 // good guys, fires, fairy, and other non-enemies
7810 // based on enemy class b/c guys in dungeons act sort of like enemies
7811 // also easier to manage all the guys this way
7812 1440 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7813 1440 {
7814 1440 mainguy=mg;
7815 1440 canfreeze=false;
7816 1440 dir=down;
7817
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1440 times.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
1440 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7818 1440 hxofs=2;
7819 1440 hzsz=8;
7820 1440 hit_width=12;
7821 1440 hit_height=17;
7822
7823
10/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 980 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 205 times.
✓ Branch 9 taken 245 times.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 191 times.
1440 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7824 {
7825 1249 superman = 1;
7826 1249 hxofs=1000;
7827 1249 }
7828 1440 }
7829
7830 563152 bool guy::animate(int32_t index)
7831 {
7832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563152 times.
563152 if(switch_hooked) return enemy::animate(index);
7833
6/6
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 269104 times.
✓ Branch 4 taken 1406 times.
✓ Branch 5 taken 717 times.
563152 if(mainguy && clk==0 && misc==0)
7834 {
7835 717 setupscreen();
7836 717 misc = 1;
7837 717 }
7838
7839
4/4
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 271014 times.
✓ Branch 3 taken 213 times.
563152 if(mainguy && fadeclk==0)
7840 213 return true;
7841
7842 562939 hp=256; // good guys never die...
7843
7844
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 562644 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 9 times.
562939 if(hclk && !clk2)
7845 {
7846 // but if they get hit...
7847 9 ++clk2; // only do this once
7848
7849
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(!get_qr(qr_NOGUYFIRES))
7850 {
7851 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7852 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7853 1 }
7854 9 }
7855
7856 562939 return enemy::animate(index);
7857 563152 }
7858
7859 566391 void guy::draw(BITMAP *dest)
7860 {
7861 566391 update_enemy_frame();
7862
7863
6/6
✓ Branch 0 taken 274338 times.
✓ Branch 1 taken 292053 times.
✓ Branch 2 taken 14309 times.
✓ Branch 3 taken 260029 times.
✓ Branch 4 taken 7153 times.
✓ Branch 5 taken 7156 times.
566391 if(!mainguy || fadeclk<0 || fadeclk&1)
7864 559235 enemy::draw(dest);
7865 566391 }
7866
7867 /*******************************/
7868 /********* Enemies *********/
7869 /*******************************/
7870
7871 374 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7872 374 {
7873 374 clk4=0;
7874 374 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7875 // Spawn type
7876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if(flags & guy_fadeflicker)
7877 {
7878 clk=0;
7879 superman = 1;
7880 fading=fade_flicker;
7881 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7882 dir=down;
7883
7884 if(!canmove(down,(zfix)8,spw_none,false))
7885 clk3=int32_t(13.0/step);
7886 }
7887
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 else if(flags & guy_fadeinstant)
7888 {
7889 clk=0;
7890 }
7891 374 SIZEflags = d->SIZEflags;
7892
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7893 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7894 // al_trace("Enemy txsz:%i\n", txsz);
7895
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7899
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7900
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7901 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7904 {
7905 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
7906 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
7907 }
7908
7909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
7910 374 }
7911
7912 78853 bool eFire::animate(int32_t index)
7913 {
7914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78853 times.
78853 if(switch_hooked) return enemy::animate(index);
7915
2/4
✓ Branch 0 taken 78853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78853 times.
78853 if(fallclk||drownclk) return enemy::animate(index);
7916
2/2
✓ Branch 0 taken 78278 times.
✓ Branch 1 taken 575 times.
78853 if(fading)
7917 {
7918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(++clk4 > 60)
7919 {
7920 clk4=0;
7921 superman=0;
7922 fading=0;
7923
7924 if(flags2&cmbflag_armos && z==0 && fakez==0)
7925 removearmos(x,y,ffcactivated);
7926
7927 clk2=0;
7928
7929 if(!canmove(down,(zfix)8,spw_none,false))
7930 {
7931 dir=0;
7932 y = y.getInt() & 0xF0;
7933 }
7934
7935 return Dead(index);
7936 }
7937
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
575 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
7938 removearmos(x,y,ffcactivated);
7939 575 }
7940
7941 78853 return enemy::animate(index);
7942 78853 }
7943
7944 166722 void eFire::draw(BITMAP *dest)
7945 {
7946 166722 update_enemy_frame();
7947 166722 enemy::draw(dest);
7948 166722 }
7949
7950 149 int32_t eFire::takehit(weapon *w, weapon* realweap)
7951 {
7952 149 int32_t wpnId = w->id;
7953 149 int32_t wpnDir = w->dir;
7954
7955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7956 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
7957 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
7958 {
7959 shield = false;
7960 flags &= ~(inv_left|inv_right|inv_back|inv_front);
7961
7962 if(get_qr(qr_BRKNSHLDTILES))
7963 o_tile=s_tile;
7964 }
7965
7966 149 int32_t ret = enemy::takehit(w,realweap);
7967 149 return ret;
7968 }
7969
7970 void eFire::break_shield()
7971 {
7972 if(!shield)
7973 return;
7974
7975 flags&=~(inv_front | inv_back | inv_left | inv_right);
7976 shield=false;
7977
7978 if(get_qr(qr_BRKNSHLDTILES))
7979 o_tile=s_tile;
7980 }
7981
7982 4900 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7983 4900 {
7984 //zprint2("npct other::other\n");
7985 4900 clk4=0;
7986 4900 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7987
7988 // Spawn type
7989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if(flags & guy_fadeflicker)
7990 {
7991 clk=0;
7992 superman = 1;
7993 fading=fade_flicker;
7994 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7995 dir=down;
7996
7997 if(!canmove(down,(zfix)8,spw_none,false))
7998 clk3=int32_t(13.0/step);
7999 }
8000
2/2
✓ Branch 0 taken 4729 times.
✓ Branch 1 taken 171 times.
4900 else if(flags & guy_fadeinstant)
8001 {
8002 171 clk=0;
8003 171 }
8004 4900 SIZEflags = d->SIZEflags;
8005
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8006 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8007 // al_trace("Enemy txsz:%i\n", txsz);
8008
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8012
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8013
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8014 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8017 {
8018 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8019 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8020 }
8021
8022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8023 4900 }
8024
8025 917976 bool eOther::animate(int32_t index)
8026 {
8027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 917976 times.
917976 if(switch_hooked) return enemy::animate(index);
8028
2/4
✓ Branch 0 taken 917976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 917976 times.
917976 if(fallclk||drownclk) return enemy::animate(index);
8029 //zprint2("npct other::animate\n");
8030
2/2
✓ Branch 0 taken 916640 times.
✓ Branch 1 taken 1336 times.
917976 if(fading)
8031 {
8032
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1335 times.
1336 if(++clk4 > 60)
8033 {
8034 1 clk4=0;
8035 1 superman=0;
8036 1 fading=0;
8037
8038
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags2&cmbflag_armos && z==0 && fakez==0)
8039 removearmos(x,y,ffcactivated);
8040
8041 1 clk2=0;
8042
8043
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!canmove(down,(zfix)8,spw_none,false))
8044 {
8045 dir=0;
8046 y = y.getInt() & 0xF0;
8047 }
8048
8049 1 return Dead(index);
8050 }
8051
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1335 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8052 removearmos(x,y,ffcactivated);
8053 1335 }
8054
8055 917975 return enemy::animate(index);
8056 917976 }
8057
8058 944738 void eOther::draw(BITMAP *dest)
8059 {
8060 944738 update_enemy_frame();
8061 944738 enemy::draw(dest);
8062 944738 }
8063
8064 5691 int32_t eOther::takehit(weapon *w, weapon* realweap)
8065 {
8066 5691 int32_t wpnId = w->id;
8067 5691 int32_t wpnDir = w->dir;
8068
8069
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 5674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
5691 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8070 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8071 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8072 {
8073 shield = false;
8074 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8075
8076 if(get_qr(qr_BRKNSHLDTILES))
8077 o_tile=s_tile;
8078 }
8079
8080 5691 int32_t ret = enemy::takehit(w,realweap);
8081 5691 return ret;
8082 }
8083
8084 void eOther::break_shield()
8085 {
8086 if(!shield)
8087 return;
8088
8089 flags&=~(inv_front | inv_back | inv_left | inv_right);
8090 shield=false;
8091
8092 if(get_qr(qr_BRKNSHLDTILES))
8093 o_tile=s_tile;
8094 }
8095
8096
8097 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8098 {
8099 clk4=0;
8100 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8101
8102 // Spawn type
8103 if(flags & guy_fadeflicker)
8104 {
8105 clk=0;
8106 superman = 1;
8107 fading=fade_flicker;
8108 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8109 dir=down;
8110
8111 if(!canmove(down,(zfix)8,spw_none,false))
8112 clk3=int32_t(13.0/step);
8113 }
8114 else if(flags & guy_fadeinstant)
8115 {
8116 clk=0;
8117 }
8118 SIZEflags = d->SIZEflags;
8119 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8120 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8121 // al_trace("Enemy txsz:%i\n", txsz);
8122 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8123 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8124 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8125 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8126 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8127 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8128 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8130 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8131 {
8132 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8133 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8134 }
8135
8136 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8137 }
8138
8139 bool eScript::animate(int32_t index)
8140 {
8141 if(switch_hooked) return enemy::animate(index);
8142 if(fallclk||drownclk) return enemy::animate(index);
8143 if(fading)
8144 {
8145 if(++clk4 > 60)
8146 {
8147 clk4=0;
8148 superman=0;
8149 fading=0;
8150
8151 if(flags2&cmbflag_armos && z==0 && fakez==0)
8152 removearmos(x,y,ffcactivated);
8153
8154 clk2=0;
8155
8156 if(!canmove(down,(zfix)8,spw_none,false))
8157 {
8158 dir=0;
8159 y = y.getInt() & 0xF0;
8160 }
8161
8162 return Dead(index);
8163 }
8164 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8165 removearmos(x,y,ffcactivated);
8166 }
8167
8168 return enemy::animate(index);
8169 }
8170
8171 void eScript::draw(BITMAP *dest)
8172 {
8173 update_enemy_frame();
8174 enemy::draw(dest);
8175 }
8176
8177 int32_t eScript::takehit(weapon *w, weapon* realweap)
8178 {
8179 int32_t wpnId = w->id;
8180 int32_t wpnDir = w->dir;
8181
8182 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8183 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8184 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8185 {
8186 shield = false;
8187 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8188
8189 if(get_qr(qr_BRKNSHLDTILES))
8190 o_tile=s_tile;
8191 }
8192
8193 int32_t ret = enemy::takehit(w,realweap);
8194 return ret;
8195 }
8196
8197 void eScript::break_shield()
8198 {
8199 if(!shield)
8200 return;
8201
8202 flags&=~(inv_front | inv_back | inv_left | inv_right);
8203 shield=false;
8204
8205 if(get_qr(qr_BRKNSHLDTILES))
8206 o_tile=s_tile;
8207 }
8208
8209
8210 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8211 {
8212 clk4=0;
8213 hyofs = -32768; //No hitbox initially.
8214 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8215
8216 // Spawn type
8217 if(flags & guy_fadeflicker)
8218 {
8219 clk=0;
8220 superman = 1;
8221 fading=fade_flicker;
8222 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8223 dir=down;
8224
8225 if(!canmove(down,(zfix)8,spw_none,false))
8226 clk3=int32_t(13.0/step);
8227 }
8228 else if(flags & guy_fadeinstant)
8229 {
8230 clk=0;
8231 }
8232 SIZEflags = d->SIZEflags;
8233 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8234 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8235 // al_trace("Enemy txsz:%i\n", txsz);
8236 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8237 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8238 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8239 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8240 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8241 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8242 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8243 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8244 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8245 {
8246 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8247 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8248 }
8249
8250 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8251 }
8252
8253 bool eFriendly::animate(int32_t index)
8254 {
8255 if(switch_hooked) return enemy::animate(index);
8256 if(fallclk||drownclk) return enemy::animate(index);
8257 if(fading)
8258 {
8259 if(++clk4 > 60)
8260 {
8261 clk4=0;
8262 superman=0;
8263 fading=0;
8264
8265 if(flags2&cmbflag_armos && z==0 && fakez==0)
8266 removearmos(x,y,ffcactivated);
8267
8268 clk2=0;
8269
8270 if(!canmove(down,(zfix)8,spw_none,false))
8271 {
8272 dir=0;
8273 y = y.getInt() & 0xF0;
8274 }
8275
8276 return Dead(index);
8277 }
8278 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8279 removearmos(x,y,ffcactivated);
8280 }
8281
8282 return enemy::animate(index);
8283 }
8284
8285 void eFriendly::draw(BITMAP *dest)
8286 {
8287 update_enemy_frame();
8288 enemy::draw(dest);
8289 }
8290
8291 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8292 {
8293 int32_t wpnId = w->id;
8294 int32_t wpnDir = w->dir;
8295
8296 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8297 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8298 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8299 {
8300 shield = false;
8301 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8302
8303 if(get_qr(qr_BRKNSHLDTILES))
8304 o_tile=s_tile;
8305 }
8306
8307 int32_t ret = enemy::takehit(w,realweap);
8308 return ret;
8309 }
8310
8311 void eFriendly::break_shield()
8312 {
8313 if(!shield)
8314 return;
8315
8316 flags&=~(inv_front | inv_back | inv_left | inv_right);
8317 shield=false;
8318
8319 if(get_qr(qr_BRKNSHLDTILES))
8320 o_tile=s_tile;
8321 }
8322
8323
8324 354130 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8325 {
8326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354130 times.
354130 if (ffcactive)
8327 {
8328 removearmosffc(ffcactive-1);
8329 return;
8330 }
8331
2/2
✓ Branch 0 taken 353464 times.
✓ Branch 1 taken 666 times.
354130 if(did_armos)
8332 {
8333 353464 return;
8334 }
8335
8336 666 did_armos=true;
8337 666 ax&=0xF0;
8338 666 ay&=0xF0;
8339 666 int32_t cd = (ax>>4)+ay;
8340 666 int32_t f = MAPFLAG(ax,ay);
8341 666 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8342
8343
2/2
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 121 times.
666 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8344 {
8345 545 return;
8346 }
8347
8348 121 tmpscr->data[cd] = tmpscr->undercombo;
8349 121 tmpscr->cset[cd] = tmpscr->undercset;
8350 121 tmpscr->sflag[cd] = 0;
8351
8352
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
121 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8353 {
8354 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8355 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8356 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8357 20 sfx(tmpscr->secretsfx);
8358 20 }
8359
8360
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
121 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8361 {
8362
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8363 {
8364 2 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8365 2 sfx(tmpscr->secretsfx);
8366 2 }
8367 2 }
8368
8369 121 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8370 354130 }
8371
8372 void enemy::removearmosffc(int32_t pos)
8373 {
8374 if(did_armos)
8375 {
8376 return;
8377 }
8378
8379 did_armos=true;
8380 ffcdata& ffc = tmpscr->ffcs[pos];
8381 newcombo const& cmb = combobuf[ffc.data];
8382 int32_t f2 = cmb.flag;
8383
8384 if(cmb.type!=cARMOS)
8385 {
8386 return;
8387 }
8388
8389 zc_ffc_set(ffc, tmpscr->undercombo);
8390 ffc.cset = tmpscr->undercset;
8391
8392 if(f2 == mfARMOS_SECRET)
8393 {
8394 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8395 ffc.cset = tmpscr->secretcset[sSTAIRS];
8396 sfx(tmpscr->secretsfx);
8397 }
8398
8399 if(f2 == mfARMOS_ITEM)
8400 {
8401 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8402 {
8403 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8404 sfx(tmpscr->secretsfx);
8405 }
8406 }
8407
8408 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8409 }
8410
8411
8412 140 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8413 140 {
8414 140 fading=fade_flicker;
8415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8416 140 dir=12;
8417 140 movestatus=1;
8418
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 step=0;
8419 140 clk=0;
8420 140 clk4=0;
8421 140 SIZEflags = d->SIZEflags;
8422
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8423 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8424 // al_trace("Enemy txsz:%i\n", txsz);
8425
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8428
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8429
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8430
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8431 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8434 {
8435 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8436 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8437 }
8438
8439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8440 140 }
8441
8442 51269 bool eGhini::animate(int32_t index)
8443 {
8444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51269 times.
51269 if(switch_hooked) return enemy::animate(index);
8445
2/4
✓ Branch 0 taken 51269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51269 times.
51269 if(fallclk||drownclk) return enemy::animate(index);
8446
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 51233 times.
51269 if(dying)
8447 36 return Dead(index);
8448
8449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51233 times.
51233 if(dmisc1)
8450 {
8451
2/2
✓ Branch 0 taken 42826 times.
✓ Branch 1 taken 8407 times.
51233 if(misc)
8452 {
8453
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 if(clk4>160)
8454 31041 misc=2;
8455
8456
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8457 42826 removearmos(x,y,ffcactivated);
8458 42826 }
8459
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 135 times.
8407 else if(clk4>=60)
8460 {
8461 135 misc=1;
8462 135 clk3=32;
8463 135 fading=0;
8464
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if (ffcactivated > 0)
8465 {
8466 guygridffc[ffcactivated-1] = 0;
8467 removearmosffc(ffcactivated-1);
8468 }
8469 else
8470 {
8471 135 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8472 135 removearmos(x,y);
8473 }
8474 135 }
8475 51233 }
8476
8477 51233 clk4++;
8478
8479 51233 return enemy::animate(index);
8480 51269 }
8481
8482 102598 void eGhini::draw(BITMAP *dest)
8483 {
8484 102598 update_enemy_frame();
8485 102598 enemy::draw(dest);
8486 102598 }
8487
8488 2 void eGhini::kickbucket()
8489 {
8490 2 hp=-1000; // don't call death_sfx()
8491 2 }
8492
8493
2/4
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
5882 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8494 2941 {
8495
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 old_y=y;
8496 2941 dir=down;
8497 2941 misc=1;
8498 2941 clk=-15;
8499
8500
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 573 times.
2941 if(!BSZ)
8501
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 clk*=zc_oldrand()%3+1;
8502
8503 // avoid divide by 0 errors
8504
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc1 == 0)
8505 dmisc1 = 24;
8506
8507
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc2 == 0)
8508 dmisc2 = 3;
8509
8510 //nets+760;
8511 2941 SIZEflags = d->SIZEflags;
8512
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8513 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8514 // al_trace("Enemy txsz:%i\n", txsz);
8515
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8518
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8519
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8520
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8521 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8522
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8524 {
8525 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8526 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8527 }
8528
8529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8530 2941 }
8531
8532 910945 bool eTektite::animate(int32_t index)
8533 {
8534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910945 times.
910945 if(switch_hooked) return enemy::animate(index);
8535
4/4
✓ Branch 0 taken 903407 times.
✓ Branch 1 taken 7538 times.
✓ Branch 2 taken 7538 times.
✓ Branch 3 taken 909605 times.
910945 if(fallclk||drownclk) return enemy::animate(index);
8536
2/2
✓ Branch 0 taken 19019 times.
✓ Branch 1 taken 890586 times.
909605 if(dying)
8537 19019 return Dead(index);
8538
8539
2/2
✓ Branch 0 taken 867887 times.
✓ Branch 1 taken 22699 times.
890586 if(clk==0)
8540 {
8541 22699 removearmos(x,y,ffcactivated);
8542 22699 }
8543
8544
2/2
✓ Branch 0 taken 557452 times.
✓ Branch 1 taken 333134 times.
890586 if(get_qr(qr_ENEMIESZAXIS))
8545 {
8546 333134 y=floor_y;
8547 333134 }
8548
8549
9/10
✓ Branch 0 taken 805094 times.
✓ Branch 1 taken 85492 times.
✓ Branch 2 taken 798089 times.
✓ Branch 3 taken 7005 times.
✓ Branch 4 taken 798089 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 786913 times.
✓ Branch 8 taken 3360 times.
✓ Branch 9 taken 11586 times.
890586 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8550 {
8551
4/4
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 310803 times.
✓ Branch 2 taken 206484 times.
✓ Branch 3 taken 271244 times.
798499 switch(misc)
8552 {
8553 case 0: // normal
8554
2/2
✓ Branch 0 taken 304080 times.
✓ Branch 1 taken 6723 times.
310803 if(!(zc_oldrand()%dmisc1))
8555 {
8556 6723 misc=1;
8557 6723 clk2=32;
8558 6723 }
8559
8560 310803 break;
8561
8562 case 1: // waiting to pounce
8563
2/2
✓ Branch 0 taken 195359 times.
✓ Branch 1 taken 11125 times.
206484 if(--clk2<=0)
8564 {
8565 11125 int32_t r=zc_oldrand();
8566 11125 misc=2;
8567 11125 step=0-(zslongToFix(dstep*100)); // initial speed
8568 11125 clk3=(r&1)+2; // left or right
8569 11125 clk2start=clk2=(r&31)+10; // flight time
8570
8571
2/2
✓ Branch 0 taken 9762 times.
✓ Branch 1 taken 1363 times.
11125 if(y<32) clk2+=2; // make them come down from top of screen
8572
8573
2/2
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 2466 times.
11125 if(y>112) clk2-=2; // make them go back up
8574
8575 11125 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8576 11125 }
8577
8578 206484 break;
8579
8580 case 2: // in flight
8581 271244 move(step);
8582
8583
2/2
✓ Branch 0 taken 130352 times.
✓ Branch 1 taken 140892 times.
271244 if(step>0) //going down
8584 {
8585
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 130196 times.
130352 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8586 {
8587 156 step=0-step;
8588 156 }
8589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8590 {
8591 step=0-step;
8592 }
8593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(ispitfall(x+8,y+16))
8594 {
8595 step=0-step;
8596 }
8597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8598 {
8599 step=0-step;
8600 }
8601
1/2
✓ Branch 0 taken 130196 times.
✗ Branch 1 not taken.
130196 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8602 {
8603 step=0-step;
8604 }
8605 130352 }
8606
2/2
✓ Branch 0 taken 9095 times.
✓ Branch 1 taken 131797 times.
140892 else if(step<0)
8607 {
8608
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 131578 times.
131797 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8609 {
8610 219 step=0-step;
8611 219 }
8612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8613 {
8614 step=0-step;
8615 }
8616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(ispitfall(x+8,y))
8617 {
8618 step=0-step;
8619 }
8620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8621 {
8622 step=0-step;
8623 }
8624
1/2
✓ Branch 0 taken 131578 times.
✗ Branch 1 not taken.
131578 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8625 {
8626 step=0-step;
8627 }
8628 131797 }
8629
8630
2/2
✓ Branch 0 taken 134483 times.
✓ Branch 1 taken 136761 times.
271244 if(clk3==left)
8631 {
8632
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 134382 times.
134483 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8633 {
8634 101 clk3^=1;
8635 101 }
8636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8637 {
8638 clk3^=1;
8639 }
8640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(ispitfall(x,y+8))
8641 {
8642 clk3^=1;
8643 }
8644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8645 {
8646 clk3^=1;
8647 }
8648
1/2
✓ Branch 0 taken 134382 times.
✗ Branch 1 not taken.
134382 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8649 {
8650 clk3^=1;
8651 }
8652 134483 }
8653 else
8654 {
8655
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 136670 times.
136761 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8656 {
8657 91 clk3^=1;
8658 91 }
8659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8660 {
8661 clk3^=1;
8662 }
8663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(ispitfall(x+16,y+8))
8664 {
8665 clk3^=1;
8666 }
8667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8668 {
8669 clk3^=1;
8670 }
8671
1/2
✓ Branch 0 taken 136670 times.
✗ Branch 1 not taken.
136670 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8672 {
8673 clk3^=1;
8674 }
8675 }
8676
8677 271244 --c;
8678
8679
4/4
✓ Branch 0 taken 81892 times.
✓ Branch 1 taken 189352 times.
✓ Branch 2 taken 178175 times.
✓ Branch 3 taken 93069 times.
271244 if(c<0 && step<zslongToFix(dstep*100))
8680 {
8681 93069 step+=zslongToFix(dmisc3*100);
8682 93069 }
8683
8684 271244 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8685
8686
2/2
✓ Branch 0 taken 270922 times.
✓ Branch 1 taken 322 times.
271244 if(x<=16-nb) clk3=right;
8687
8688
2/2
✓ Branch 0 taken 270702 times.
✓ Branch 1 taken 542 times.
271244 if(x>=224+nb) clk3=left;
8689
8690 271244 x += (clk3==left) ? -1 : 1;
8691
8692
4/4
✓ Branch 0 taken 15373 times.
✓ Branch 1 taken 255871 times.
✓ Branch 2 taken 4984 times.
✓ Branch 3 taken 250887 times.
271244 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8693 {
8694
4/4
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 9728 times.
✓ Branch 2 taken 484 times.
✓ Branch 3 taken 177 times.
20357 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8695 {
8696 177 step=0-step;
8697 177 y--;
8698 177 }
8699
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 7892 times.
10212 else if(zc_oldrand()%dmisc2) //land and wait
8700 {
8701 7892 clk=misc=0;
8702 7892 } //land and jump again
8703 else
8704 {
8705 2320 misc=1;
8706 2320 clk2=0;
8707 }
8708 10389 }
8709
8710 261276 break;
8711 } // switch
8712 788531 }
8713
8714
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 551254 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
884388 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8715 {
8716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
8717 {
8718 int32_t tempy = floor_y;
8719 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8720 floor_y = y;
8721 y=tempy-fakez;
8722 old_y = y;
8723 }
8724 else
8725 {
8726 106683 int32_t tempy = floor_y;
8727
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 100927 times.
✓ Branch 3 taken 5756 times.
✓ Branch 4 taken 49170 times.
✓ Branch 5 taken 51757 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8728 106683 floor_y = y;
8729 106683 y=tempy-z;
8730 106683 old_y = y;
8731 }
8732 106683 }
8733
8734
4/4
✓ Branch 0 taken 7005 times.
✓ Branch 1 taken 877383 times.
✓ Branch 2 taken 1407 times.
✓ Branch 3 taken 5598 times.
884388 if(stunclk && (clk&31)==1)
8735 5598 clk=0;
8736
8737 884388 return enemy::animate(index);
8738 903407 }
8739
8740 330586 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8741 {
8742
5/6
✓ Branch 0 taken 161030 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 161030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136696 times.
✓ Branch 5 taken 24334 times.
330586 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8743 24334 return;
8744
8745 306252 int32_t tempy=yofs;
8746 306252 int32_t fdiv = frate/4;
8747
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8748
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8749 306252 efrate:((clk>=(frate>>1))?1:0);
8750 306252 flip = 0;
8751 306252 shadowtile = wpnsbuf[spr_shadow].tile;
8752
8753
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 if(get_qr(qr_NEWENEMYTILES))
8754 {
8755
2/2
✓ Branch 0 taken 200675 times.
✓ Branch 1 taken 105577 times.
306252 if(misc==0)
8756 {
8757 105577 shadowtile+=f2;
8758 105577 }
8759
2/2
✓ Branch 0 taken 91502 times.
✓ Branch 1 taken 109173 times.
200675 else if(misc!=1)
8760 109173 shadowtile+=2;
8761 306252 }
8762 else
8763 {
8764 if(misc==0)
8765 {
8766 shadowtile += f2 ? 1 : 0;
8767 }
8768 else if(misc!=1)
8769 {
8770 ++shadowtile;
8771 }
8772 }
8773
8774 306252 yofs+=8;
8775
8776
4/4
✓ Branch 0 taken 136696 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 84452 times.
✓ Branch 3 taken 52244 times.
306252 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8777 {
8778
6/6
✓ Branch 0 taken 26557 times.
✓ Branch 1 taken 25687 times.
✓ Branch 2 taken 48843 times.
✓ Branch 3 taken 3401 times.
✓ Branch 4 taken 24406 times.
✓ Branch 5 taken 24437 times.
52244 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8779 52244 }
8780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306252 times.
306252 if(!shadow_overpit(this))
8781 306252 enemy::drawshadow(dest,translucent);
8782 306252 yofs=tempy;
8783 330586 }
8784
8785 1500560 void eTektite::draw(BITMAP *dest)
8786 {
8787 1500560 update_enemy_frame();
8788 1500560 enemy::draw(dest);
8789 1500560 }
8790
8791 413 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8792 413 {
8793
2/4
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
413 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8794 413 superman=1;
8795 413 dir=8;
8796 413 hxofs=1000;
8797 413 mainguy=false;
8798 413 count_enemy=false;
8799
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8800 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8801 // al_trace("Enemy txsz:%i\n", txsz);
8802
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
8803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
8804
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
8805
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
8806
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
8807
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
8808 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8809
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
8810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8811 {
8812 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
8813 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8814 }
8815
8816
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
8817 413 }
8818
8819 228794 bool eItemFairy::animate(int32_t index)
8820 {
8821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(switch_hooked) return enemy::animate(index);
8822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(dying)
8823 return Dead(index);
8824
8825 //if(clk>32)
8826 228794 misc=1;
8827 228794 bool w=watch;
8828 228794 watch=false;
8829 228794 variable_walk_8(misc?3:0,0,8,spw_floater);
8830 228794 watch=w;
8831
8832
2/2
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 227687 times.
228794 if(clk==0)
8833 {
8834 1107 removearmos(x,y,ffcactivated);
8835 1107 }
8836
8837 228794 return enemy::animate(index);
8838 228794 }
8839
8840 458954 void eItemFairy::draw(BITMAP *dest)
8841 {
8842 //these are here to bypass compiler warnings about unused arguments
8843 458954 dest=dest;
8844 458954 }
8845
8846 1048 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8847 1048 {
8848 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8849
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1048 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1048 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1048 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1048 times.
✗ Branch 19 not taken.
1048 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8850 1048 dir=8;
8851 1048 movestatus=1;
8852 1048 clk=0;
8853
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 step=0;
8854 //nets+720;
8855 1048 SIZEflags = d->SIZEflags;
8856
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8857 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8858 // al_trace("Enemy txsz:%i\n", txsz);
8859
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8860
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8861
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8862
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8863
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8864
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8865 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8866
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8868 {
8869 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8870 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8871 }
8872
8873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8874 1048 }
8875
8876 300264 bool ePeahat::animate(int32_t index)
8877 {
8878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300264 times.
300264 if(switch_hooked) return enemy::animate(index);
8879
2/4
✓ Branch 0 taken 300264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300264 times.
300264 if(fallclk||drownclk) return enemy::animate(index);
8880
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 300186 times.
300264 if(slide())
8881 {
8882 78 return false;
8883 }
8884
8885
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 299672 times.
300186 if(dying)
8886 514 return Dead(index);
8887
8888
2/2
✓ Branch 0 taken 297855 times.
✓ Branch 1 taken 1817 times.
299672 if(clk==0)
8889 {
8890 1817 removearmos(x,y,ffcactivated);
8891 1817 }
8892
8893
4/4
✓ Branch 0 taken 296892 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 144455 times.
✓ Branch 3 taken 152437 times.
299672 if(stunclk==0 && clk>96)
8894 152437 misc=1;
8895
8896
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
299672 if(!watch)
8897
2/2
✓ Branch 0 taken 197329 times.
✓ Branch 1 taken 99941 times.
297270 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8898
8899
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 199654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
299672 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8900 {
8901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8902 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8903 100018 }
8904
8905
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
299672 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8906 1634 superman=0;
8907 else
8908
2/2
✓ Branch 0 taken 6888 times.
✓ Branch 1 taken 291150 times.
298038 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8909 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8910
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 103653 times.
299672 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8911 {
8912
2/2
✓ Branch 0 taken 193242 times.
✓ Branch 1 taken 2777 times.
196019 if ( stunclk ) --stunclk;
8913 196019 }
8914 103653 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8915 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8916
8917
8918
2/2
✓ Branch 0 taken 299448 times.
✓ Branch 1 taken 224 times.
299672 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8919
8920 299672 return enemy::animate(index);
8921 300264 }
8922
8923 126460 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8924 {
8925 126460 int32_t tempy=yofs;
8926 126460 flip = 0;
8927 126460 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8928
8929
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 38371 times.
126460 if(!get_qr(qr_ENEMIESZAXIS))
8930 {
8931 38371 yofs+=8;
8932 38371 yofs+=int32_t(step/zslongToFix(dstep*10));
8933 38371 }
8934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126460 times.
126460 if(!shadow_overpit(this))
8935 126460 enemy::drawshadow(dest,translucent);
8936 126460 yofs=tempy;
8937 126460 }
8938
8939 694948 void ePeahat::draw(BITMAP *dest)
8940 {
8941 694948 update_enemy_frame();
8942 694948 enemy::draw(dest);
8943 694948 }
8944
8945 1383 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8946 {
8947 1383 int32_t wpnId = w->id;
8948 1383 int32_t enemyHitWeapon = w->parentitem;
8949
8950
3/6
✓ Branch 0 taken 1383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1383 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1383 times.
1383 if(dying || clk<0 || hclk>0)
8951 return 0;
8952
8953
4/4
✓ Branch 0 taken 1186 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 129 times.
1542 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8954 // fire boomerang, for nailing peahats
8955
4/6
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1027 times.
✓ Branch 3 taken 159 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 159 times.
1186 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8956 1156 return 0;
8957
8958 // Time for a kludge...
8959 227 int32_t s = superman;
8960 227 superman = 0;
8961 227 int32_t ret = enemy::takehit(w,realweap);
8962 227 superman = s;
8963
8964 // Anyway...
8965
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 141 times.
227 if(stunclk == 160)
8966 {
8967 141 clk2=0;
8968 141 movestatus=0;
8969 141 misc=0;
8970 141 clk=0;
8971 141 step=0;
8972 141 }
8973
8974 227 return ret;
8975 1383 }
8976
8977 // auomatically kill off enemy (for rooms with ringleaders)
8978 void ePeahat::kickbucket()
8979 {
8980 hp=-1000; // don't call death_sfx()
8981 }
8982
8983 1694 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8984 1694 {
8985 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8986
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 941 times.
1694 if(dmisc1==0)
8987 {
8988 941 misc=-1; //Line of Sight leevers
8989 941 clk-=16;
8990 941 }
8991 1694 clk3 = 0;
8992 //nets+1460;
8993 1694 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8994 1694 submerged = false;
8995 1694 SIZEflags = d->SIZEflags;
8996
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8997 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8998 // al_trace("Enemy txsz:%i\n", txsz);
8999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9003
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9004
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9005 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9006
1/4
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9008 {
9009 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9010 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9011 }
9012
9013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9014 1694 }
9015
9016 bool eLeever::isSubmerged() const
9017 {
9018 Z_scripterrlog("misc is: %d\n", misc);
9019 return misc <= 0;
9020
9021 }
9022
9023 499943 bool eLeever::animate(int32_t index)
9024 {
9025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 499943 times.
499943 if(switch_hooked) return enemy::animate(index);
9026
2/4
✓ Branch 0 taken 499943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 499943 times.
499943 if(fallclk||drownclk)
9027 {
9028 return enemy::animate(index);
9029 }
9030
2/2
✓ Branch 0 taken 16506 times.
✓ Branch 1 taken 483437 times.
499943 if(dying)
9031 16506 return Dead(index);
9032
9033
2/2
✓ Branch 0 taken 463097 times.
✓ Branch 1 taken 20340 times.
483437 if(clk==0)
9034 {
9035 20340 removearmos(x,y,ffcactivated);
9036 20340 }
9037
9038
4/4
✓ Branch 0 taken 393192 times.
✓ Branch 1 taken 90245 times.
✓ Branch 2 taken 2529 times.
✓ Branch 3 taken 390663 times.
483437 if(clk>=0 && !slide())
9039 {
9040 // switch(d->misc1)
9041
2/2
✓ Branch 0 taken 156396 times.
✓ Branch 1 taken 234267 times.
390663 switch(dmisc1)
9042 {
9043 case 0: //line of sight
9044 case 2:
9045
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✓ Branch 2 taken 17136 times.
✓ Branch 3 taken 15898 times.
✓ Branch 4 taken 7088 times.
✓ Branch 5 taken 43977 times.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 2915 times.
156396 switch(misc) //is this leever active
9046 {
9047 case -1: //submerged
9048 {
9049
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67550 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
9050
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 59941 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
67550 if((dmisc1==2)&&(zc_oldrand()&255))
9051 {
9052 7582 break;
9053 }
9054
9055 59968 int32_t active=0;
9056
9057
2/2
✓ Branch 0 taken 424896 times.
✓ Branch 1 taken 59968 times.
484864 for(int32_t i=0; i<guys.Count(); i++)
9058 {
9059
4/4
✓ Branch 0 taken 348604 times.
✓ Branch 1 taken 76292 times.
✓ Branch 2 taken 229810 times.
✓ Branch 3 taken 118794 times.
424896 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
9060 {
9061 118794 ++active;
9062 118794 }
9063 424896 }
9064
9065
2/2
✓ Branch 0 taken 59147 times.
✓ Branch 1 taken 821 times.
59968 if(active<((dmisc1==2)?1:2))
9066 {
9067 821 misc=0; //activate this one
9068 821 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
9069 821 }
9070 }
9071 59968 break;
9072
9073 case 0:
9074 {
9075
9076
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17136 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9077 {
9078 misc=1;
9079 clk2=0;
9080 }
9081
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 17100 times.
17136 else if (clk3<=0)
9082 {
9083 36 misc = -1;
9084 36 break;
9085 }
9086 17100 int32_t s=0;
9087
9088
2/2
✓ Branch 0 taken 112208 times.
✓ Branch 1 taken 17100 times.
129308 for(int32_t i=0; i<guys.Count(); i++)
9089 {
9090
4/4
✓ Branch 0 taken 74011 times.
✓ Branch 1 taken 38197 times.
✓ Branch 2 taken 71849 times.
✓ Branch 3 taken 2162 times.
112208 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
9091 {
9092 2162 ++s;
9093 2162 }
9094 112208 }
9095
9096
2/2
✓ Branch 0 taken 2162 times.
✓ Branch 1 taken 14938 times.
17100 if(s>0)
9097 {
9098 2162 break;
9099 }
9100
9101 14938 int32_t d2=zc_oldrand()&1;
9102
9103
2/2
✓ Branch 0 taken 5336 times.
✓ Branch 1 taken 9602 times.
14938 if(HeroDir()>=left)
9104 {
9105 9602 d2+=2;
9106 9602 }
9107
9108
4/4
✓ Branch 0 taken 14295 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 13995 times.
14938 if(canplace(d2) || canplace(d2^1))
9109 {
9110 943 misc=1;
9111 943 clk2=0;
9112 943 clk=0;
9113 943 }
9114 }
9115 14938 break;
9116
9117 case 1:
9118
9119
3/8
✓ Branch 0 taken 14970 times.
✓ Branch 1 taken 928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14970 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15898 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9120
9121 15898 break;
9122
9123 case 2:
9124
9125
3/8
✓ Branch 0 taken 6227 times.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6227 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7088 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9126
9127 7088 break;
9128
9129 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9130 case 3:
9131
9132
5/6
✓ Branch 0 taken 41679 times.
✓ Branch 1 taken 2298 times.
✓ Branch 2 taken 41679 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2066 times.
✓ Branch 5 taken 39613 times.
43977 if(stunclk || frozenclock || watch) break;
9133
9134
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 39534 times.
39613 if(scored) dir^=1;
9135
9136
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 39402 times.
39613 if(!canmove(dir,false)) misc=4;
9137 39402 else move(zslongToFix(dstep*100));
9138
9139 39613 break;
9140
9141 case 4:
9142
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1832 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9143
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 197 times.
1832 if(--clk2<=16)
9144 {
9145 197 misc=5;
9146 197 clk=8;
9147 197 }
9148
9149 1832 break;
9150
9151 case 5:
9152
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2915 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9153
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 175 times.
2915 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9154
9155 2915 break;
9156 } // switch(misc)
9157
9158 156396 break;
9159
9160 default: //random
9161 // step=d->misc3/100.0;
9162
9163 234267 step=zslongToFix(dmisc3*100);
9164
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
234267 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9165 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9166 {
9167 if (clk2 < 48) clk2+=2;
9168 if (clk2 >= 300) clk2-=2;
9169 }
9170
9171
2/2
✓ Branch 0 taken 27519 times.
✓ Branch 1 taken 206748 times.
234267 if(clk2<32) misc=1;
9172
2/2
✓ Branch 0 taken 13816 times.
✓ Branch 1 taken 192932 times.
206748 else if(clk2<48) misc=2;
9173
2/2
✓ Branch 0 taken 140831 times.
✓ Branch 1 taken 52101 times.
192932 else if(clk2<300)
9174 {
9175 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9176 {
9177 fix_coords();
9178 }*/
9179 140831 misc=3;
9180 140831 step = zslongToFix(dstep*100);
9181 140831 }
9182
2/2
✓ Branch 0 taken 4801 times.
✓ Branch 1 taken 47300 times.
52101 else if(clk2<316) misc=2;
9183
2/2
✓ Branch 0 taken 23641 times.
✓ Branch 1 taken 23659 times.
47300 else if(clk2<412) misc=1;
9184
2/2
✓ Branch 0 taken 23490 times.
✓ Branch 1 taken 169 times.
23659 else if(clk2<540)
9185 {
9186 23490 misc=0;
9187 23490 step=0;
9188 23490 }
9189 169 else clk2=0;
9190
9191
2/2
✓ Branch 0 taken 233418 times.
✓ Branch 1 taken 849 times.
234267 if(clk2==48) clk=0;
9192
9193 // variable_walk(d->rate, d->homing, 0);
9194 234267 variable_walk(rate, homing, 0);
9195 234267 } // switch(dmisc1)
9196 390663 }
9197
9198 483437 hxofs=(misc>=2)?0:1000;
9199 483437 return enemy::animate(index);
9200 499943 }
9201
9202 29233 bool eLeever::canplace(int32_t d2)
9203 {
9204 29233 int32_t nx=HeroX();
9205 29233 int32_t ny=HeroY();
9206
9207
2/2
✓ Branch 0 taken 10404 times.
✓ Branch 1 taken 18829 times.
29233 if(d2<left) ny&=0xF0;
9208 18829 else nx&=0xF0;
9209
9210
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
✓ Branch 2 taken 5231 times.
✓ Branch 3 taken 9395 times.
✓ Branch 4 taken 9434 times.
29233 switch(d2)
9211 {
9212 // case up: ny-=((d->misc1==0)?32:48); break;
9213 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9214 // case left: nx-=((d->misc1==0)?32:48); break;
9215 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9216 case up:
9217
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 28 times.
5173 ny-=((dmisc1==0||dmisc1==2)?32:48);
9218 5173 break;
9219
9220 case down:
9221
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5200 times.
5231 ny+=((dmisc1==0||dmisc1==2)?32:48);
9222
9223
4/4
✓ Branch 0 taken 2757 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 9 times.
5231 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9224
9225 5231 break;
9226
9227 case left:
9228
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 600 times.
9395 nx-=((dmisc1==0||dmisc1==2)?32:48);
9229 9395 break;
9230
9231 case right:
9232
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 8839 times.
9434 nx+=((dmisc1==0||dmisc1==2)?32:48);
9233
9234
4/4
✓ Branch 0 taken 6054 times.
✓ Branch 1 taken 3380 times.
✓ Branch 2 taken 5499 times.
✓ Branch 3 taken 555 times.
9434 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9235
9236 9434 break;
9237 }
9238
9239
4/4
✓ Branch 0 taken 10020 times.
✓ Branch 1 taken 19213 times.
✓ Branch 2 taken 4483 times.
✓ Branch 3 taken 5537 times.
29233 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9240 23696 return false;
9241
9242
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 5098 times.
5537 if(d2>=left)
9243
4/4
✓ Branch 0 taken 2481 times.
✓ Branch 1 taken 2617 times.
✓ Branch 2 taken 4594 times.
✓ Branch 3 taken 504 times.
5098 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9244 4594 return false;
9245
9246 943 x=nx;
9247 943 y=ny;
9248 943 dir=d2^1;
9249 943 return true;
9250 29233 }
9251
9252 500779 void eLeever::draw(BITMAP *dest)
9253 {
9254 // cs=d->cset;
9255 500779 cs=dcset;
9256 500779 update_enemy_frame();
9257
2/4
✓ Branch 0 taken 500779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500779 times.
500779 if(!fallclk&&!drownclk)
9258 {
9259
2/2
✓ Branch 0 taken 301145 times.
✓ Branch 1 taken 199634 times.
500779 switch(misc)
9260 {
9261 case -1:
9262 case 0:
9263 199634 return;
9264 }
9265 301145 }
9266
9267 301145 enemy::draw(dest);
9268 500779 }
9269
9270 523 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9271 523 {
9272 //zprint2("eWallM::eWallM\n");
9273 523 hashero=false;
9274 //nets+1000;
9275 523 SIZEflags = d->SIZEflags;
9276
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9277 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9278 // al_trace("Enemy txsz:%i\n", txsz);
9279
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9281
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9283
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9284
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9285 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9286
1/4
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9288 {
9289 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9290 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9291 }
9292
9293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9294 523 }
9295
9296 321974 bool eWallM::animate(int32_t index)
9297 {
9298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 321974 times.
321974 if(switch_hooked) return enemy::animate(index);
9299
2/4
✓ Branch 0 taken 321974 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321974 times.
321974 if(fallclk||drownclk)
9300 {
9301 return enemy::animate(index);
9302 }
9303
2/2
✓ Branch 0 taken 6282 times.
✓ Branch 1 taken 315692 times.
321974 if(dying)
9304 6282 return Dead(index);
9305
9306
2/2
✓ Branch 0 taken 295632 times.
✓ Branch 1 taken 20060 times.
315692 if(clk==0)
9307 {
9308 20060 removearmos(x,y,ffcactivated);
9309 20060 }
9310
9311 315692 hxofs=1000;
9312
2/2
✓ Branch 0 taken 81640 times.
✓ Branch 1 taken 234052 times.
315692 if(misc==0) //inside wall, ready to spawn?
9313 {
9314 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
9315 //zprint2("frame is: %d\n",frame);
9316 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
9317
4/4
✓ Branch 0 taken 154566 times.
✓ Branch 1 taken 79486 times.
✓ Branch 2 taken 9024 times.
✓ Branch 3 taken 145542 times.
234052 if(frame-wallm_load_clk>80 && clk>=0)
9318 {
9319 //zprint2("getting wall\n");
9320 145542 int32_t wall=hero_on_wall();
9321 //zprint2("Wallmaster wall is %d\n",wall);
9322 145542 int32_t wallm_cnt=0;
9323
9324
2/2
✓ Branch 0 taken 1108757 times.
✓ Branch 1 taken 145542 times.
1254299 for(int32_t i=0; i<guys.Count(); i++)
9325
2/2
✓ Branch 0 taken 421543 times.
✓ Branch 1 taken 687214 times.
1795971 if(((enemy*)guys.spr(i))->family==eeWALLM)
9326 {
9327 687214 int32_t m=((enemy*)guys.spr(i))->misc;
9328
9329
4/4
✓ Branch 0 taken 32180 times.
✓ Branch 1 taken 655034 times.
✓ Branch 2 taken 20369 times.
✓ Branch 3 taken 11811 times.
687214 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9330 {
9331 11811 ++wallm_cnt;
9332 11811 }
9333 687214 }
9334
9335
2/2
✓ Branch 0 taken 145029 times.
✓ Branch 1 taken 513 times.
145542 if(wall>0)
9336 {
9337 513 --wall;
9338 513 misc=1; //emerging from the wall?
9339 //zprint2("Wallmaster is emerging\n");
9340 513 clk2=0;
9341 513 clk3=wall^1;
9342 513 wallm_load_clk=frame;
9343
9344
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 201 times.
513 if(wall<=down)
9345 {
9346
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 258 times.
312 if(HeroDir()==left)
9347 54 dir=right;
9348 else
9349 258 dir=left;
9350 312 }
9351 else
9352 {
9353
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 162 times.
201 if(HeroDir()==up)
9354 39 dir=down;
9355 else
9356 162 dir=up;
9357 }
9358
9359
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 69 times.
513 switch(wall)
9360 {
9361 case up:
9362 152 y=0;
9363 152 break;
9364
9365 case down:
9366 160 y=160;
9367 160 break;
9368
9369 case left:
9370 132 x=0;
9371 132 break;
9372
9373 case right:
9374 69 x=240;
9375 69 break;
9376 }
9377
9378 //zprint2("Wallmaster (p1) x is %d\n",x);
9379 //zprint2("Wallmaster (p1) y is %d\n",y);
9380
9381
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 54 times.
513 switch(dir)
9382 {
9383 case up:
9384 162 y=(HeroY()+48-(wallm_cnt&1)*12);
9385 162 flip=wall&1;
9386 162 break;
9387
9388 case down:
9389 39 y=(HeroY()-48+(wallm_cnt&1)*12);
9390 39 flip=((wall&1)^1)+2;
9391 39 break;
9392
9393 case left:
9394 258 x=(HeroX()+48-(wallm_cnt&1)*12);
9395 258 flip=(wall==up?2:0)+1;
9396 258 break;
9397
9398 case right:
9399 54 x=(HeroX()-48+(wallm_cnt&1)*12);
9400 54 flip=(wall==up?2:0);
9401 54 break;
9402 }
9403
9404 //zprint2("Wallmaster (p2) x is %d\n",x);
9405 //zprint2("Wallmaster (p2) y is %d\n",y);
9406 513 }
9407 145542 }
9408 234052 }
9409 else
9410 81640 wallm_crawl();
9411
9412 315692 return enemy::animate(index);
9413 321974 }
9414
9415 81640 void eWallM::wallm_crawl()
9416 {
9417 81640 bool w=watch;
9418 81640 hxofs=0;
9419
9420
2/2
✓ Branch 0 taken 591 times.
✓ Branch 1 taken 81049 times.
81640 if(slide())
9421 {
9422 591 return;
9423 }
9424
9425 // if(dying || watch || (!hashero && stunclk))
9426
6/8
✓ Branch 0 taken 81049 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80760 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 66702 times.
✓ Branch 5 taken 14058 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66702 times.
81049 if(dying || (!hashero && ( stunclk || frozenclock )))
9427 {
9428 14058 return;
9429 }
9430
9431 66991 watch=false;
9432 66991 ++clk2;
9433 // Misc1: slightly different movement
9434 //zprint2("wallmaster crawl\n");
9435 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
9436 66991 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9437
9438 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9439 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
9440 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
9441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66991 times.
66991 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9442 //zprint2("wallmaster crawl misc is: %d\n", misc);
9443
5/6
✓ Branch 0 taken 5942 times.
✓ Branch 1 taken 61049 times.
✓ Branch 2 taken 4472 times.
✓ Branch 3 taken 1470 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4472 times.
66991 if(w&&misc>=3&&misc<=5)
9444 {
9445 4472 --clk2;
9446 4472 }
9447
9448
4/4
✓ Branch 0 taken 28236 times.
✓ Branch 1 taken 31313 times.
✓ Branch 2 taken 7328 times.
✓ Branch 3 taken 114 times.
66991 switch(misc)
9449 {
9450 case 1:
9451 case 2:
9452 31313 zc_swap(dir,clk3);
9453 31313 move(step);
9454 31313 zc_swap(dir,clk3);
9455 31313 break;
9456
9457 case 3:
9458 case 4:
9459 case 5:
9460
2/2
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 23764 times.
28236 if(w)
9461 {
9462 4472 watch=w;
9463 4472 return;
9464 }
9465
9466 23764 move(step);
9467 23764 break;
9468
9469 case 6:
9470 case 7:
9471 7328 zc_swap(dir,clk3);
9472 7328 dir^=1;
9473 7328 move(step);
9474 7328 dir^=1;
9475 7328 zc_swap(dir,clk3);
9476 7328 break;
9477
9478 default:
9479 114 misc=0;
9480 114 break;
9481 }
9482
9483 62519 watch=w;
9484 81640 }
9485
9486 3 void eWallM::grabhero()
9487 {
9488 3 hashero=true;
9489 3 superman=1;
9490 3 }
9491
9492 322782 void eWallM::draw(BITMAP *dest)
9493 {
9494 322782 dummy_bool[1]=hashero;
9495 322782 update_enemy_frame();
9496
9497
4/6
✓ Branch 0 taken 234569 times.
✓ Branch 1 taken 88213 times.
✓ Branch 2 taken 234569 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 234569 times.
322782 if(misc>0 || fallclk||drownclk)
9498 {
9499 88213 masked_draw(dest,16,playing_field_offset+16,224,144);
9500 88213 }
9501
9502 // enemy::draw(dest);
9503 // tile = clk&8 ? 128:129;
9504 322782 }
9505
9506 bool eWallM::isSubmerged() const
9507 {
9508 return ( !misc );
9509 }
9510
9511 742 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9512 742 {
9513
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 ox=x; //original x
9514
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 oy=y; //original y
9515
2/2
✓ Branch 0 taken 676 times.
✓ Branch 1 taken 66 times.
742 if(get_qr(qr_TRAPPOSFIX))
9516 {
9517
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9518 66 }
9519
9520 742 mainguy=false;
9521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9522 //nets+420;
9523 742 dummy_int[1]=0;
9524 742 SIZEflags = d->SIZEflags;
9525
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9526 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9527 // al_trace("Enemy txsz:%i\n", txsz);
9528
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9532
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9533
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9534 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9537 {
9538 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9539 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9540 }
9541
9542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9543 742 }
9544
9545 534456 bool eTrap::animate(int32_t index)
9546 {
9547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 534456 times.
534456 if(switch_hooked) return enemy::animate(index);
9548
2/4
✓ Branch 0 taken 534456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 534456 times.
534456 if(fallclk||drownclk) return enemy::animate(index);
9549
2/2
✓ Branch 0 taken 524072 times.
✓ Branch 1 taken 10384 times.
534456 if(clk<0)
9550 10384 return enemy::animate(index);
9551
9552
2/2
✓ Branch 0 taken 490954 times.
✓ Branch 1 taken 33118 times.
524072 if(clk==0)
9553 {
9554 33118 removearmos(x,y,ffcactivated);
9555 33118 }
9556
9557
2/2
✓ Branch 0 taken 142952 times.
✓ Branch 1 taken 381120 times.
524072 if(misc==0) // waiting
9558 {
9559 381120 ox = x;
9560 381120 oy = y;
9561 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9562 381120 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9563
9564
4/4
✓ Branch 0 taken 127495 times.
✓ Branch 1 taken 253625 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 53982 times.
381120 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9565 {
9566 53982 dir=down;
9567 53982 }
9568
4/4
✓ Branch 0 taken 220423 times.
✓ Branch 1 taken 106715 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 146910 times.
327138 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9569 {
9570 146910 dir=right;
9571 146910 }
9572
4/4
✓ Branch 0 taken 112988 times.
✓ Branch 1 taken 67240 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 39475 times.
180228 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9573 {
9574 39475 dir=up;
9575 39475 }
9576 else
9577 {
9578 140753 dir=left;
9579 }
9580
9581 381120 int32_t d2=lined_up(15,true);
9582
9583
4/4
✓ Branch 0 taken 135666 times.
✓ Branch 1 taken 245454 times.
✓ Branch 2 taken 684811 times.
✓ Branch 3 taken 303691 times.
615292 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9584
2/2
✓ Branch 0 taken 129243 times.
✓ Branch 1 taken 174448 times.
303691 ((d2>down) && (dmisc1==2)) ||
9585
2/2
✓ Branch 0 taken 118337 times.
✓ Branch 1 taken 70965 times.
174448 ((d2>right) && (!dmisc1)) ||
9586
2/2
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
189302 ((d2<l_up) && (dmisc1==4)) ||
9587
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 168538 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
65634 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9588
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
168538 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9589 {
9590 1516570 d2=-1;
9591 1516570 }
9592
9593
4/4
✓ Branch 0 taken 11339 times.
✓ Branch 1 taken 201243 times.
✓ Branch 2 taken 10273 times.
✓ Branch 3 taken 1066 times.
212582 if(d2!=-1 && trapmove(d2))
9594 {
9595 1066 dir=d2;
9596 1066 misc=1;
9597 1066 clk2=(dir==down)?3:0;
9598 1066 }
9599 212582 }
9600
9601
2/2
✓ Branch 0 taken 316873 times.
✓ Branch 1 taken 38661 times.
355534 if(misc==1) // charging
9602 {
9603 38661 clk2=(clk2+1)&3;
9604 38661 step=(clk2==3)?1:2;
9605
9606
4/4
✓ Branch 0 taken 38531 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 860 times.
✓ Branch 3 taken 37671 times.
38661 if(!trapmove(dir) || clip())
9607 {
9608 990 misc=2;
9609
9610
1/2
✓ Branch 0 taken 990 times.
✗ Branch 1 not taken.
990 if(dir<l_up)
9611 {
9612 990 dir=dir^1;
9613 990 }
9614 else
9615 {
9616 dir=dir^3;
9617 }
9618 990 }
9619 else
9620 {
9621 37671 sprite::move(step);
9622 }
9623 38661 }
9624
9625
2/2
✓ Branch 0 taken 249187 times.
✓ Branch 1 taken 106347 times.
355534 if(misc==2) // retreating
9626 {
9627 106347 step=(++clk2&1)?1:0;
9628
9629
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 17320 times.
✓ Branch 2 taken 39848 times.
✓ Branch 3 taken 11903 times.
✓ Branch 4 taken 37276 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106347 switch(dir)
9630 {
9631 case up:
9632
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 17181 times.
17320 if(int32_t(y)<=oy) goto trap_rest;
9633 17181 else sprite::move(step);
9634
9635 17181 break;
9636
9637 case left:
9638
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 39620 times.
39848 if(int32_t(x)<=ox) goto trap_rest;
9639 39620 else sprite::move(step);
9640
9641 39620 break;
9642
9643 case down:
9644
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 11791 times.
11903 if(int32_t(y)>=oy) goto trap_rest;
9645 11791 else sprite::move(step);
9646
9647 11791 break;
9648
9649 case right:
9650
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 37049 times.
37276 if(int32_t(x)>=ox) goto trap_rest;
9651 37049 else sprite::move(step);
9652
9653 37049 break;
9654
9655 case l_up:
9656 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9657 else sprite::move(step);
9658
9659 break;
9660
9661 case r_up:
9662 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9663 else sprite::move(step);
9664
9665 break;
9666
9667 case l_down:
9668 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9669 else sprite::move(step);
9670
9671 break;
9672
9673 case r_down:
9674 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9675 else sprite::move(step);
9676
9677 break;
9678 trap_rest:
9679 {
9680 706 x=ox;
9681 706 y=oy;
9682 706 misc=0;
9683 }
9684 706 }
9685 106347 }
9686
9687 355534 return enemy::animate(index);
9688 365918 }
9689
9690 50000 bool eTrap::trapmove(int32_t ndir)
9691 {
9692
2/2
✓ Branch 0 taken 35733 times.
✓ Branch 1 taken 14267 times.
50000 if(get_qr(qr_MEANTRAPS))
9693 {
9694
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 34393 times.
35733 if(tmpscr->flags2&fFLOATTRAPS)
9695 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9696
9697 34393 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9698 }
9699
9700
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
9701 2766 return false;
9702
9703
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
9704 return false;
9705
9706
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
9707 return false;
9708
9709
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
9710 return false;
9711
9712
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
9713 718 return false;
9714
9715
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
9716 488 return false;
9717
9718
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
9719 return false;
9720
9721
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
9722 return false;
9723
9724
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
9725 return false;
9726
9727
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
9728 return false;
9729
9730 10295 return true;
9731 50000 }
9732
9733 38531 bool eTrap::clip()
9734 {
9735
2/2
✓ Branch 0 taken 33513 times.
✓ Branch 1 taken 5018 times.
38531 if(get_qr(qr_MEANPLACEDTRAPS))
9736 {
9737
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✓ Branch 2 taken 1926 times.
✓ Branch 3 taken 985 times.
✓ Branch 4 taken 1377 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5018 switch(dir)
9738 {
9739 case up:
9740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
730 if(y<=0) return true;
9741
9742 730 break;
9743
9744 case down:
9745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1926 times.
1926 if(y>=160) return true;
9746
9747 1926 break;
9748
9749 case left:
9750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985 times.
985 if(x<=0) return true;
9751
9752 985 break;
9753
9754 case right:
9755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(x>=240) return true;
9756
9757 1377 break;
9758
9759 case l_up:
9760 if(y<=0||x<=0) return true;
9761
9762 break;
9763
9764 case l_down:
9765 if(y>=160||x<=0) return true;
9766
9767 break;
9768
9769 case r_up:
9770 if(y<=0||x>=240) return true;
9771
9772 break;
9773
9774 case r_down:
9775 if(y>=160||x>=240) return true;
9776
9777 break;
9778 }
9779
9780 5018 return false;
9781 }
9782 else
9783 {
9784
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3745 times.
✓ Branch 2 taken 4135 times.
✓ Branch 3 taken 12605 times.
✓ Branch 4 taken 13028 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33513 switch(dir)
9785 {
9786 case up:
9787
4/4
✓ Branch 0 taken 3691 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3546 times.
✓ Branch 3 taken 145 times.
3745 if(oy>80 && y<=86) return true;
9788
9789 3600 break;
9790
9791 case down:
9792
4/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3903 times.
✓ Branch 3 taken 151 times.
4135 if(oy<80 && y>=80) return true;
9793
9794 3984 break;
9795
9796 case left:
9797
4/4
✓ Branch 0 taken 12515 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 12236 times.
✓ Branch 3 taken 279 times.
12605 if(ox>128 && x<=124) return true;
9798
9799 12326 break;
9800
9801 case right:
9802
3/4
✓ Branch 0 taken 13028 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12743 times.
✓ Branch 3 taken 285 times.
13028 if(ox<120 && x>=116) return true;
9803
9804 12743 break;
9805
9806 case l_up:
9807 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9808
9809 break;
9810
9811 case l_down:
9812 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9813
9814 break;
9815
9816 case r_up:
9817 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9818
9819 break;
9820
9821 case r_down:
9822 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9823
9824 break;
9825 }
9826
9827 32653 return false;
9828 }
9829 38531 }
9830
9831 537872 void eTrap::draw(BITMAP *dest)
9832 {
9833 537872 update_enemy_frame();
9834 537872 enemy::draw(dest);
9835 537872 }
9836
9837 2407 int32_t eTrap::takehit(weapon*,weapon*)
9838 {
9839 2407 return 0;
9840 }
9841
9842 147 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9843 147 {
9844 147 lasthit=-1;
9845 147 lasthitclk=0;
9846 147 mainguy=false;
9847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9848
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 step=2;
9849
3/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9850 {
9851
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 dir=(x<=112)?right:left;
9852 67 }
9853 else
9854 {
9855
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 dir=(y<=72)?down:up;
9856 }
9857
9858
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(get_qr(qr_TRAPPOSFIX))
9859 {
9860 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9861 }
9862
9863 //nets+((id==eTRAP_LR)?540:520);
9864 147 dummy_int[1]=0;
9865 147 SIZEflags = d->SIZEflags;
9866
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9867 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9868 // al_trace("Enemy txsz:%i\n", txsz);
9869
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9870
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9871
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9873
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9874
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9875 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9878 {
9879 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9880 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9881 }
9882
9883
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9884 147 }
9885
9886 85467 bool eTrap2::animate(int32_t index)
9887 {
9888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85467 times.
85467 if(switch_hooked) return enemy::animate(index);
9889
2/4
✓ Branch 0 taken 85467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85467 times.
85467 if(fallclk||drownclk) return enemy::animate(index);
9890
2/2
✓ Branch 0 taken 83409 times.
✓ Branch 1 taken 2058 times.
85467 if(clk<0)
9891 2058 return enemy::animate(index);
9892
9893
2/2
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 78120 times.
83409 if(clk==0)
9894 {
9895 5289 removearmos(x,y,ffcactivated);
9896 5289 }
9897
9898
2/2
✓ Branch 0 taken 79017 times.
✓ Branch 1 taken 4392 times.
83409 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9899 {
9900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
9901 {
9902 --lasthitclk;
9903 }
9904 else
9905 {
9906 4392 lasthit=-1;
9907 }
9908
9909 4392 bool hitenemy=false;
9910
9911
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
9912 {
9913
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
9914 {
9915
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
9916 {
9917 lasthit=j;
9918 lasthitclk=10;
9919 hitenemy=true;
9920 guys.spr(j)->lasthit=index;
9921 guys.spr(j)->lasthitclk=10;
9922 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9923 }
9924 52704 }
9925 57096 }
9926
9927
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
9928 {
9929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
9930 {
9931 48 lasthit=-1;
9932 48 lasthitclk=0;
9933 48 }
9934
9935
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_qr(qr_MORESOUNDS))
9936 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9937
9938 48 dir=dir^1;
9939 48 }
9940
9941 4392 sprite::move(step);
9942 4392 }
9943 else
9944 {
9945
3/4
✓ Branch 0 taken 77234 times.
✓ Branch 1 taken 1783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77234 times.
79017 if(!trapmove(dir) || clip())
9946 {
9947
1/2
✓ Branch 0 taken 1783 times.
✗ Branch 1 not taken.
1783 if(get_qr(qr_MORESOUNDS))
9948 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9949
9950 1783 dir=dir^1;
9951 1783 }
9952
9953 79017 sprite::move(step);
9954 }
9955
9956 83409 return enemy::animate(index);
9957 85467 }
9958
9959 83457 bool eTrap2::trapmove(int32_t ndir)
9960 {
9961
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 81579 times.
83457 if(tmpscr->flags2&fFLOATTRAPS)
9962 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9963
9964 81579 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9965 83457 }
9966
9967 81578 bool eTrap2::clip()
9968 {
9969
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23387 times.
✓ Branch 2 taken 23376 times.
✓ Branch 3 taken 17291 times.
✓ Branch 4 taken 17524 times.
81578 switch(dir)
9970 {
9971 case up:
9972
1/2
✓ Branch 0 taken 23387 times.
✗ Branch 1 not taken.
23387 if(y<=0) return true;
9973
9974 23387 break;
9975
9976 case down:
9977
1/2
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
23376 if(y>=160) return true;
9978
9979 23376 break;
9980
9981 case left:
9982
1/2
✓ Branch 0 taken 17291 times.
✗ Branch 1 not taken.
17291 if(x<=0) return true;
9983
9984 17291 break;
9985
9986 case right:
9987
1/2
✓ Branch 0 taken 17524 times.
✗ Branch 1 not taken.
17524 if(x>=240) return true;
9988
9989 17524 break;
9990 }
9991
9992 81578 return false;
9993 81578 }
9994
9995 85478 void eTrap2::draw(BITMAP *dest)
9996 {
9997 85478 update_enemy_frame();
9998 85478 enemy::draw(dest);
9999 85478 }
10000
10001 531 int32_t eTrap2::takehit(weapon*,weapon*)
10002 {
10003 531 return 0;
10004 }
10005
10006 226 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10007 226 {
10008 //do not show "enemy appering" anim -DD
10009 226 clk=0;
10010 226 mainguy=false;
10011 226 clk2=-14;
10012 //Enemy Editor Size Tab
10013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10014 226 else hxofs = -2;
10015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10016 226 else hyofs = -2;
10017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10018 226 else hit_width = 20;
10019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10020 226 else hit_height=20;
10021
10022
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10023
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10025
1/4
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10027 {
10028 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10029 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10030 }
10031
10032
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10033 //nets+1640;
10034 226 }
10035
10036 79036 bool eRock::animate(int32_t index)
10037 {
10038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(switch_hooked) return enemy::animate(index);
10039
2/4
✓ Branch 0 taken 79036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79036 times.
79036 if(fallclk||drownclk) return enemy::animate(index);
10040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(dying)
10041 return Dead(index);
10042
10043
2/2
✓ Branch 0 taken 73519 times.
✓ Branch 1 taken 5517 times.
79036 if(clk==0)
10044 {
10045 5517 removearmos(x,y,ffcactivated);
10046 5517 }
10047
10048
2/2
✓ Branch 0 taken 78591 times.
✓ Branch 1 taken 445 times.
79036 if(++clk2==0) // start it
10049 {
10050 445 x=zc_oldrand()&0xF0;
10051 445 y=0;
10052 445 clk3=0;
10053 445 clk2=zc_oldrand()&15;
10054 445 }
10055
10056
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 64376 times.
79036 if(clk2>16) // move it
10057 {
10058
2/2
✓ Branch 0 taken 62155 times.
✓ Branch 1 taken 2221 times.
64376 if(clk3<=0) // start bounce
10059 {
10060 2221 dir=zc_oldrand()&1;
10061
10062
2/2
✓ Branch 0 taken 1966 times.
✓ Branch 1 taken 255 times.
2221 if(x<32) dir=1;
10063
10064
2/2
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 181 times.
2221 if(x>208) dir=0;
10065 2221 }
10066
10067
2/2
✓ Branch 0 taken 62303 times.
✓ Branch 1 taken 2073 times.
64376 if(clk3<13+16)
10068 {
10069 62303 x += dir ? 1 : -1; //right, left
10070 62303 dummy_int[1]=dir;
10071
10072
2/2
✓ Branch 0 taken 4436 times.
✓ Branch 1 taken 57867 times.
62303 if(clk3<2)
10073 {
10074 4436 y-=2; //up
10075 4436 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10076 4436 }
10077
2/2
✓ Branch 0 taken 6614 times.
✓ Branch 1 taken 51253 times.
57867 else if(clk3<5)
10078 {
10079 6614 y--; //up
10080 6614 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10081 6614 }
10082
2/2
✓ Branch 0 taken 6569 times.
✓ Branch 1 taken 44684 times.
51253 else if(clk3<8)
10083 {
10084 6569 dummy_int[2]=(dummy_int[1]==1)?right:left;
10085 6569 }
10086
2/2
✓ Branch 0 taken 6518 times.
✓ Branch 1 taken 38166 times.
44684 else if(clk3<11)
10087 {
10088 6518 y++; //down
10089 6518 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10090 6518 }
10091 else
10092 {
10093 38166 y+=2; //down
10094 38166 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10095 }
10096
10097 62303 ++clk3;
10098 62303 }
10099
2/2
✓ Branch 0 taken 1793 times.
✓ Branch 1 taken 280 times.
2073 else if(y<176)
10100 1793 clk3=0; // next bounce
10101 else
10102 280 clk2 = -(zc_oldrand()&63); // back to top
10103 64376 }
10104
10105 79036 return enemy::animate(index);
10106 79036 }
10107
10108 21684 void eRock::drawshadow(BITMAP *dest, bool translucent)
10109 {
10110
2/2
✓ Branch 0 taken 2969 times.
✓ Branch 1 taken 18715 times.
21684 if(clk2>=0)
10111 {
10112 18715 int32_t tempy=yofs;
10113 18715 flip = 0;
10114 18715 int32_t fdiv = frate/4;
10115
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10116
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t f2=get_qr(qr_NEWENEMYTILES)?
10117 18715 efrate:((clk>=(frate>>1))?1:0);
10118 18715 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10119
10120 18715 yofs+=8;
10121
6/6
✓ Branch 0 taken 8758 times.
✓ Branch 1 taken 9957 times.
✓ Branch 2 taken 16513 times.
✓ Branch 3 taken 2202 times.
✓ Branch 4 taken 8135 times.
✓ Branch 5 taken 8378 times.
18715 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18715 times.
18715 if(!shadow_overpit(this))
10123 18715 enemy::drawshadow(dest, translucent);
10124 18715 yofs=tempy;
10125 18715 }
10126 21684 }
10127
10128 79097 void eRock::draw(BITMAP *dest)
10129 {
10130
4/6
✓ Branch 0 taken 10969 times.
✓ Branch 1 taken 68128 times.
✓ Branch 2 taken 10969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10969 times.
79097 if(clk2>=0 || fallclk||drownclk)
10131 {
10132 68128 int32_t tempdir=dir;
10133 68128 dir=dummy_int[2];
10134 68128 update_enemy_frame();
10135 68128 enemy::draw(dest);
10136 68128 dir=tempdir;
10137 68128 }
10138 79097 }
10139
10140 859 int32_t eRock::takehit(weapon*,weapon*)
10141 {
10142 859 return 0;
10143 }
10144
10145 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10146 30 {
10147 30 clk=0;
10148 30 mainguy=false;
10149 30 clk2=-14;
10150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10151 30 else hxofs= -10;
10152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10153 30 else hyofs=-10;
10154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10155 30 else hit_width=36;
10156
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10157 30 else hit_height=36;
10158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10159 30 else hzsz=16; //can't be jumped
10160
10161
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10162
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10163
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10164
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10166 {
10167 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10168 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10169 }
10170
10171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10172 //nets+1680;
10173 30 }
10174
10175 4440 bool eBoulder::animate(int32_t index)
10176 {
10177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
10178
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
10179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
10180 return Dead(index);
10181
10182
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
10183 {
10184 290 removearmos(x,y,ffcactivated);
10185 290 }
10186
10187 zfix *vert;
10188
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10189
10190
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10191 {
10192 32 x=zc_oldrand()&0xF0;
10193 32 y=-32;
10194 32 clk3=0;
10195 32 clk2=zc_oldrand()&15;
10196 32 }
10197
10198
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10199 {
10200
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10201 {
10202 131 dir=zc_oldrand()&1;
10203
10204
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10205
10206
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10207 131 }
10208
10209
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10210 {
10211 3487 x += dir ? 1 : -1; //right, left
10212 3487 dummy_int[1]=dir;
10213
10214
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10215 {
10216 261 y-=2; //up
10217 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10218 261 }
10219
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10220 {
10221 382 y--; //up
10222 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10223 382 }
10224
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10225 {
10226 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10227 376 }
10228
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10229 {
10230 367 y++; //down
10231 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10232 367 }
10233 else
10234 {
10235 2101 y+=2; //down
10236 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10237 }
10238
10239 3487 ++clk3;
10240 3487 }
10241
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10242 101 clk3=0; // next bounce
10243 else
10244 10 clk2 = -(zc_oldrand()&63); // back to top
10245 3598 }
10246
10247 4440 return enemy::animate(index);
10248 4440 }
10249
10250 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10251 {
10252
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10253 {
10254 3868 int32_t tempy=yofs;
10255 3868 flip = 0;
10256 3868 int32_t f2=((clk<<2)/frate)<<1;
10257 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10258
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10259
10260 3868 yofs+=8;
10261 3868 xofs-=8;
10262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10263 3868 enemy::drawshadow(dest, translucent);
10264 3868 xofs+=16;
10265 3868 ++shadowtile;
10266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10267 3868 enemy::drawshadow(dest, translucent);
10268 3868 yofs+=16;
10269 3868 shadowtile+=20;
10270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10271 3868 enemy::drawshadow(dest, translucent);
10272 3868 xofs-=16;
10273 3868 --shadowtile;
10274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10275 3868 enemy::drawshadow(dest, translucent);
10276 3868 xofs+=8;
10277 3868 yofs=tempy;
10278 3868 }
10279 4440 }
10280
10281 4440 void eBoulder::draw(BITMAP *dest)
10282 {
10283
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10284 {
10285 3868 int32_t tempdir=dir;
10286 3868 dir=dummy_int[2];
10287 3868 update_enemy_frame();
10288 3868 dir=tempdir;
10289 3868 xofs-=8;
10290 3868 yofs-=8;
10291 3868 drawblock(dest,15);
10292 3868 xofs+=8;
10293 3868 yofs+=8;
10294 // enemy::draw(dest);
10295 3868 }
10296 4440 }
10297
10298 int32_t eBoulder::takehit(weapon*,weapon*)
10299 {
10300 return 0;
10301 }
10302
10303 2257 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10304
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 1743 times.
2257 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10305 2257 {
10306 /* fixing
10307 hp=1;
10308 */
10309 2257 mainguy=false;
10310
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10311 2257 hclk=clk; // the "no fire" range
10312 2257 clk=0;
10313 2257 clk3=96;
10314 2257 timer=0;
10315
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if(o_tile==0)
10316 {
10317 2250 superman=1;
10318 2250 hxofs=1000;
10319 2250 }
10320 2257 SIZEflags = d->SIZEflags;
10321
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10322 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10323 // al_trace("Enemy txsz:%i\n", txsz);
10324
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10327
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10328
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10329
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10330 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10331
1/4
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10333 {
10334 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10335 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10336 }
10337
10338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10339 2257 }
10340
10341 1551984 bool eProjectile::animate(int32_t index)
10342 {
10343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1551984 times.
1551984 if(switch_hooked) return enemy::animate(index);
10344
2/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1551984 times.
1551984 if(fallclk||drownclk) return enemy::animate(index);
10345
2/2
✓ Branch 0 taken 1544504 times.
✓ Branch 1 taken 7480 times.
1551984 if(clk==0)
10346 {
10347 7480 removearmos(x,y,ffcactivated);
10348 7480 }
10349
10350 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10351 1551984 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10352
10353
4/4
✓ Branch 0 taken 507924 times.
✓ Branch 1 taken 1044060 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 229115 times.
1551984 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10354 {
10355 229115 dir=down;
10356 229115 }
10357
4/4
✓ Branch 0 taken 850200 times.
✓ Branch 1 taken 472669 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 571391 times.
1322869 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10358 {
10359 571391 dir=right;
10360 571391 }
10361
4/4
✓ Branch 0 taken 519744 times.
✓ Branch 1 taken 231734 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 240935 times.
751478 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10362 {
10363 240935 dir=up;
10364 240935 }
10365 else
10366 {
10367 510543 dir=left;
10368 }
10369
10370
3/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 812552 times.
✓ Branch 3 taken 739432 times.
1551984 if(!stunclk && ++clk3>80)
10371 {
10372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 739432 times.
739432 if(dmisc1==9) // Breath type
10373 {
10374 if(timer==0)
10375 {
10376 unsigned r=zc_oldrand();
10377
10378 if(!(r&63))
10379 {
10380 timer=zc_oldrand()%50+50;
10381 }
10382 }
10383
10384 if(timer>0)
10385 {
10386 if(timer%4==0)
10387 {
10388 FireBreath(false);
10389 }
10390
10391 if(--timer==0)
10392 {
10393 clk3=0;
10394 }
10395 }
10396 }
10397
10398 else // Not breath type
10399 {
10400 739432 unsigned r=zc_oldrand();
10401
10402
4/4
✓ Branch 0 taken 11616 times.
✓ Branch 1 taken 727816 times.
✓ Branch 2 taken 839 times.
✓ Branch 3 taken 10777 times.
739432 if(!(r&63) && !HeroInRange(minRange))
10403 {
10404 10777 FireWeapon();
10405
10406
3/4
✓ Branch 0 taken 8406 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
10838 if(get_qr(qr_BROKENSTATUES)==0 &&
10407
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8345 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
8406 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10408 {
10409
2/2
✓ Branch 0 taken 7924 times.
✓ Branch 1 taken 482 times.
8406 if(!((r>>7)&15))
10410 {
10411 482 x-=4;
10412 482 FireWeapon();
10413 482 x+=4;
10414 482 }
10415 8406 }
10416
10417 10777 clk3=0;
10418 10777 }
10419 }
10420 739432 }
10421
10422 1551984 return enemy::animate(index);
10423 1551984 }
10424
10425 1557825 void eProjectile::draw(BITMAP *dest)
10426 {
10427 1557825 update_enemy_frame();
10428 1557825 enemy::draw(dest);
10429 1557825 }
10430
10431 90 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10432 90 {
10433 90 hxofs=1000;
10434 90 }
10435
10436 12175 void eTrigger::draw(BITMAP *dest)
10437 {
10438 12175 update_enemy_frame();
10439 12175 enemy::draw(dest);
10440 12175 }
10441
10442 void eTrigger::death_sfx()
10443 {
10444 //silent death
10445 }
10446
10447 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10448 {
10449 o_tile+=wpnsbuf[iwNPCs].tile;
10450 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10451 SIZEflags = d->SIZEflags;
10452 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10453 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10454 // al_trace("Enemy txsz:%i\n", txsz);
10455 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10456 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10457 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10458 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10459 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10460 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10461 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10462 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10463 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10464 {
10465 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10466 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10467 }
10468
10469 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10470 }
10471
10472 bool eNPC::animate(int32_t index)
10473 {
10474 if(switch_hooked) return enemy::animate(index);
10475 if(dying)
10476 return Dead(index);
10477
10478 if(clk==0)
10479 {
10480 removearmos(x,y,ffcactivated);
10481 }
10482
10483 switch(dmisc2)
10484 {
10485 case 0:
10486 {
10487 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10488 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10489
10490 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10491 {
10492 dir=down;
10493 }
10494
10495 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10496 {
10497 dir=right;
10498 }
10499 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10500 {
10501 dir=up;
10502 }
10503 else
10504 {
10505 dir=left;
10506 }
10507 }
10508 break;
10509
10510 case 1:
10511 halting_walk(rate, homing, 0, hrate, 48);
10512
10513 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10514 {
10515 newdir(rate, homing, 0);
10516 clk2=48;
10517 ++misc;
10518 }
10519
10520 if(clk2==0)
10521 misc=0;
10522
10523 break;
10524 }
10525
10526 return enemy::animate(index);
10527 }
10528
10529 void eNPC::draw(BITMAP *dest)
10530 {
10531 update_enemy_frame();
10532 enemy::draw(dest);
10533 }
10534
10535 int32_t eNPC::takehit(weapon*,weapon*)
10536 {
10537 return 0;
10538 }
10539
10540 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10541 94 {
10542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10543 {
10544 94 o_tile=clk;
10545 94 cs=id>>12;
10546 94 }
10547
10548 94 id=id&0xFFF;
10549 94 clk=0;
10550
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10551 94 mainguy=false;
10552 94 SIZEflags = d->SIZEflags;
10553
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10554 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10555 // al_trace("Enemy txsz:%i\n", txsz);
10556
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10560
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10561
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10562 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10563
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10565 {
10566 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10567 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10568 }
10569
10570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10571 94 }
10572
10573 81 void eSpinTile::facehero()
10574 {
10575
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10576 {
10577
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10578 1 dir = up;
10579 else
10580 dir = down;
10581 1 }
10582 else
10583 {
10584 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10585 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10586
10587
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10588 {
10589 12 dir=l_down;
10590 12 }
10591
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10592 {
10593 1 dir=down;
10594 1 }
10595
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10596 {
10597 12 dir=r_down;
10598 12 }
10599
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10600 {
10601 6 dir=right;
10602 6 }
10603
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10604 {
10605 17 dir=r_up;
10606 17 }
10607
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10608 {
10609 8 dir=up;
10610 8 }
10611
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10612 {
10613 6 dir=l_up;
10614 6 }
10615 else
10616 {
10617 18 dir=left;
10618 }
10619 }
10620 81 }
10621
10622
10623 15539 bool eSpinTile::animate(int32_t index)
10624 {
10625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10626
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10627
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10628 {
10629 1152 return Dead(index);
10630 }
10631
10632
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10633 {
10634 1241 removearmos(x,y,ffcactivated);
10635 1241 }
10636
10637 14387 ++misc;
10638
10639
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10640 {
10641 81 facehero();
10642 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10643 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10644 81 angular=true;
10645 81 angle=ddir;
10646 81 step=zslongToFix(dstep*100);
10647 81 }
10648
10649
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10650 52 kickbucket();
10651
10652 14387 sprite::move(step);
10653 14387 return enemy::animate(index);
10654 15539 }
10655
10656 15457 void eSpinTile::draw(BITMAP *dest)
10657 {
10658 15457 update_enemy_frame();
10659 15457 y-=(misc>>4);
10660 15457 yofs+=2;
10661 15457 enemy::draw(dest);
10662 15457 yofs-=2;
10663 15457 y+=(misc>>4);
10664 15457 }
10665
10666 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10667 {
10668 15457 flip = 0;
10669 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10670 15457 yofs+=4;
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10672 15457 enemy::drawshadow(dest, translucent);
10673 15457 yofs-=4;
10674 15457 }
10675
10676 1605 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10677 1605 {
10678 //these are here to bypass compiler warnings about unused arguments
10679 1605 Clk=Clk;
10680 1605 mainguy=false;
10681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10682 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10683 {
10684 clk=1;
10685 }*/
10686 //nets+880;
10687 1605 SIZEflags = d->SIZEflags;
10688
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10689 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10690 // al_trace("Enemy txsz:%i\n", txsz);
10691
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10693
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10694
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10695
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10696
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10697 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10698
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10700 {
10701 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10702 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10703 }
10704
10705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10706 1605 }
10707
10708 392118 void eZora::facehero()
10709 {
10710
2/2
✓ Branch 0 taken 6564 times.
✓ Branch 1 taken 385554 times.
392118 if(Hero.x-x==0)
10711 {
10712 6564 dir=(Hero.y+8<y)?up:down;
10713 6564 }
10714 else
10715 {
10716 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10717 385554 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10718
10719
4/4
✓ Branch 0 taken 80572 times.
✓ Branch 1 taken 304982 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 49955 times.
385554 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10720 {
10721 49955 dir=l_down;
10722 49955 }
10723
4/4
✓ Branch 0 taken 57428 times.
✓ Branch 1 taken 278171 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 26811 times.
335599 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10724 {
10725 26811 dir=down;
10726 26811 }
10727
4/4
✓ Branch 0 taken 77619 times.
✓ Branch 1 taken 231169 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 47002 times.
308788 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10728 {
10729 47002 dir=r_down;
10730 47002 }
10731
4/4
✓ Branch 0 taken 102786 times.
✓ Branch 1 taken 159000 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 72169 times.
261786 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10732 {
10733 72169 dir=right;
10734 72169 }
10735
4/4
✓ Branch 0 taken 83714 times.
✓ Branch 1 taken 105903 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 53097 times.
189617 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10736 {
10737 53097 dir=r_up;
10738 53097 }
10739
4/4
✓ Branch 0 taken 54641 times.
✓ Branch 1 taken 81879 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 24024 times.
136520 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10740 {
10741 24024 dir=up;
10742 24024 }
10743
4/4
✓ Branch 0 taken 76377 times.
✓ Branch 1 taken 36119 times.
✓ Branch 2 taken 45760 times.
✓ Branch 3 taken 30617 times.
112496 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10744 {
10745 45760 dir=l_up;
10746 45760 }
10747 else
10748 {
10749 66736 dir=left;
10750 }
10751 }
10752 392118 }
10753
10754 554408 bool eZora::animate(int32_t index)
10755 {
10756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 554408 times.
554408 if(switch_hooked) return enemy::animate(index);
10757
2/2
✓ Branch 0 taken 1868 times.
✓ Branch 1 taken 552540 times.
554408 if(dying)
10758 1868 return Dead(index);
10759
10760
2/2
✓ Branch 0 taken 548931 times.
✓ Branch 1 taken 3609 times.
552540 if(clk==0)
10761 {
10762 3609 removearmos(x,y,ffcactivated);
10763 3609 }
10764
10765
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 552509 times.
552540 if(watch)
10766 {
10767 31 ++clock_zoras[id];
10768 31 return true;
10769 }
10770
10771
2/2
✓ Branch 0 taken 160391 times.
✓ Branch 1 taken 392118 times.
552509 if(get_qr(qr_NEWENEMYTILES))
10772 {
10773 392118 facehero();
10774 392118 }
10775
10776
6/6
✓ Branch 0 taken 3333 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 2684 times.
✓ Branch 3 taken 537009 times.
✓ Branch 4 taken 4269 times.
✓ Branch 5 taken 2014 times.
552509 switch(clk)
10777 {
10778 case 0: // reposition him
10779 {
10780 4269 int32_t t=0;
10781 4269 int32_t pos2=zc_oldrand()%160 + 16;
10782 4269 bool placed=false;
10783
10784
4/4
✓ Branch 0 taken 4246 times.
✓ Branch 1 taken 20492 times.
✓ Branch 2 taken 12637 times.
✓ Branch 3 taken 3609 times.
24738 while(!placed && t<160)
10785 {
10786 12637 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10787
5/6
✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 8311 times.
✓ Branch 2 taken 4326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 3586 times.
16553 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4326 times.
4326 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10789
3/4
✓ Branch 0 taken 4326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3916 times.
✓ Branch 3 taken 3916 times.
4326 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10790 {
10791 3586 x=(pos2&15)<<4;
10792 3586 y=pos2&0xF0;
10793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3586 times.
3586 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10794 3586 hxofs=1000; // avoid hit detection
10795 3586 stunclk=0;
10796 3586 placed=true;
10797 3586 }
10798
10799 20469 pos2+=19;
10800
10801
2/2
✓ Branch 0 taken 18055 times.
✓ Branch 1 taken 2414 times.
20469 if(pos2>=176)
10802 2414 pos2-=160;
10803
10804 20469 ++t;
10805 }
10806
10807
3/4
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3586 times.
3609 if(!placed || whistleclk>=88) // can't place him, he's gone
10808 23 return true;
10809
10810 }
10811 3586 break;
10812
10813 case 35:
10814
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 965 times.
3333 if(!get_qr(qr_NEWENEMYTILES))
10815 {
10816 965 dir=(Hero.y+8<y)?up:down;
10817 965 }
10818
10819 3333 hxofs=0;
10820 3333 break;
10821
10822 case 35+19:
10823 3200 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10824 3200 sfx(wpnsfx(wpn),pan(int32_t(x)));
10825 3200 break;
10826
10827 case 35+66:
10828 2684 hxofs=1000;
10829 2684 break;
10830
10831 case 198:
10832 2014 clk=-1;
10833 2014 break;
10834 }
10835
10836 551826 return enemy::animate(index);
10837 553748 }
10838
10839 554283 void eZora::draw(BITMAP *dest)
10840 {
10841
2/2
✓ Branch 0 taken 10764 times.
✓ Branch 1 taken 543519 times.
554283 if(clk<3)
10842 10764 return;
10843
10844 543519 update_enemy_frame();
10845 543519 enemy::draw(dest);
10846 554283 }
10847
10848 bool eZora::isSubmerged() const
10849 {
10850 return ( clk < 3 );
10851 }
10852
10853
3/6
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26760 times.
✗ Branch 5 not taken.
53520 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10854 26760 {
10855 26760 multishot= timer = fired = dashing = 0;
10856 26760 hashero = false;
10857 26760 dummy_bool[0]=false;
10858 26760 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10859
5/6
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 71 times.
26760 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10860 {
10861
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 step=zslongToFix(dmisc10*100);
10862
10863
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64 times.
76 if(anim==aARMOS4) o_tile+=20;
10864 76 }
10865
10866
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
26760 if(flags & guy_fadeflicker)
10867 {
10868 147 clk=0;
10869 147 superman = 1;
10870 147 fading=fade_flicker;
10871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10872 147 dir=down;
10873
10874
4/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 80 times.
147 if(!canmove(down,(zfix)8,spw_none,false))
10875
3/6
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
67 clk3=int32_t(13.0/step);
10876 147 }
10877
2/2
✓ Branch 0 taken 26612 times.
✓ Branch 1 taken 1 times.
26613 else if(flags & guy_fadeinstant)
10878 {
10879 1 clk=0;
10880 1 }
10881
10882
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 shadowdistance = 0;
10883 26760 clk4 = clk5 = 0;
10884 //nets+2380;
10885 26760 SIZEflags = d->SIZEflags;
10886
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10887 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10888 // al_trace("Enemy txsz:%i\n", txsz);
10889
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10890
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10893
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10894
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10895 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10898 {
10899 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10900 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10901 }
10902
10903
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10904 26760 }
10905
10906 9630028 bool eStalfos::animate(int32_t index)
10907 {
10908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9630028 times.
9630028 if(switch_hooked) return enemy::animate(index);
10909
3/4
✓ Branch 0 taken 9629886 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9629886 times.
9630028 if(fallclk||drownclk)
10910 {
10911 142 return enemy::animate(index);
10912 }
10913
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 9421987 times.
9629886 if(dying)
10914 {
10915
2/2
✓ Branch 0 taken 207868 times.
✓ Branch 1 taken 31 times.
207899 if(hashero)
10916 {
10917 31 Hero.setEaten(0);
10918 31 hashero=false;
10919 31 }
10920
10921
10/14
✓ Branch 0 taken 20374 times.
✓ Branch 1 taken 187525 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 19234 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
207899 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10922 {
10923 49 hp=-1000;
10924
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10925 49 Ewpns.add(ew);
10926 49 ew->fakez = fakez;
10927
10928
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
10929 {
10930 49 ew->step=0;
10931 49 ew->id=wpn;
10932 49 ew->misc=50;
10933 49 ew->clk=48;
10934 49 }
10935
10936 49 fired=true;
10937 49 }
10938
6/6
✓ Branch 0 taken 95092 times.
✓ Branch 1 taken 112758 times.
✓ Branch 2 taken 77556 times.
✓ Branch 3 taken 17536 times.
✓ Branch 4 taken 77538 times.
✓ Branch 5 taken 18 times.
207850 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10939 {
10940
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10941 {
10942 1 int32_t wpn2 = wpn+dmisc3;
10943
10944
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10945 {
10946 wpn2=wpn;
10947 }
10948
10949 1 dummy_bool[0]=true;
10950 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10951 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10952 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10953 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10954 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10955 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10956 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10957 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10958 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10959 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10960 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10961 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10962 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10963 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10964 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10965 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10966 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10967 1 }
10968 18 }
10969
10970 207899 KillWeapon();
10971 207899 return Dead(index);
10972 }
10973 //vire split
10974 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10975 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10976
13/14
✓ Branch 0 taken 11844 times.
✓ Branch 1 taken 9410143 times.
✓ Branch 2 taken 11844 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 11695 times.
✓ Branch 6 taken 819531 times.
✓ Branch 7 taken 8602307 times.
✓ Branch 8 taken 818273 times.
✓ Branch 9 taken 1258 times.
✓ Branch 10 taken 4401 times.
✓ Branch 11 taken 813872 times.
✓ Branch 12 taken 803 times.
✓ Branch 13 taken 3598 times.
9421987 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10977 {
10978 952 stop_bgsfx(index);
10979 952 int32_t kids = guys.Count();
10980 952 int32_t id2=dmisc3;
10981
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 952 times.
2842 for(int32_t i=0; i < dmisc4; i++)
10982 {
10983 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10984
4/6
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1334 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1890 times.
1890 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10985 1890 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10986 1890 }
10987
10988
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(itemguy) // Hand down the carried item
10989 {
10990 guycarryingitem = guys.Count()-1;
10991 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10992 itemguy = false;
10993 }
10994
10995
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(hashero)
10996 {
10997 Hero.setEaten(0);
10998 hashero=false;
10999 }
11000
11001
4/4
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 803 times.
✓ Branch 3 taken 135 times.
952 if(deadsfx > 0 && dmisc2==e2tSPLIT)
11002 135 sfx(deadsfx,pan(int32_t(x)));
11003
11004 952 return true;
11005 }
11006 /*
11007 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
11008 {
11009 stop_bgsfx(index);
11010 int32_t kids = guys.Count();
11011 int32_t id2=dmisc3;
11012
11013 for(int32_t i=0; i < dmisc4; i++)
11014 {
11015 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
11016 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
11017 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11018 }
11019
11020 if(itemguy) // Hand down the carried item
11021 {
11022 guycarryingitem = guys.Count()-1;
11023 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11024 itemguy = false;
11025 }
11026
11027 if(hashero)
11028 {
11029 Hero.setEaten(0);
11030 hashero=false;
11031 }
11032
11033 return true;
11034 }
11035 */
11036
2/2
✓ Branch 0 taken 12521 times.
✓ Branch 1 taken 9408514 times.
9421035 if(fading)
11037 {
11038
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 12312 times.
12521 if(++clk4 > 60)
11039 {
11040 209 clk4=0;
11041 209 superman=0;
11042 209 fading=0;
11043
11044
4/6
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
209 if(flags2&cmbflag_armos && z==0 && fakez == 0)
11045 {
11046 //if a custom size (not 16px by 16px)
11047
11048 //if a custom size (not 16px by 16px)
11049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (ffcactivated)
11050 removearmosffc(ffcactivated-1);
11051 else
11052 {
11053
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11054 {
11055 //zprint("spawn big enemy from armos\n");
11056 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11057 for(int32_t dx = 0; dx < tysz; dx ++)
11058 {
11059 for(int32_t dy = 0; dy < tysz; dy++)
11060 {
11061 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
11062 did_armos = false;
11063 }
11064 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
11065 did_armos = false;
11066 }
11067 for(int32_t dy = 0; dy < tysz; dy ++)
11068 {
11069 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
11070 did_armos = false;
11071 }
11072 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
11073 }
11074 146 else removearmos(x,y);
11075 }
11076 /*
11077 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11078 {
11079 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11080 for(int32_t dx = 0; dx < hxsz; dx += 16)
11081 {
11082 for(int32_t dy = 0; dy < hysz; dy += 16)
11083 {
11084 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
11085 did_armos = false;
11086 }
11087 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11088 did_armos = false;
11089 }
11090 for(int32_t dy = 0; dy < hysz; dy += 16)
11091 {
11092 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
11093 did_armos = false;
11094 }
11095 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11096 }
11097 else removearmos(x,y,ffcactivated);
11098 */
11099
11100 146 }
11101
11102 209 clk2=0;
11103
11104 209 newdir();
11105 209 }
11106 12312 else return enemy::animate(index);
11107 209 }
11108
6/8
✓ Branch 0 taken 33168 times.
✓ Branch 1 taken 9375346 times.
✓ Branch 2 taken 33168 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33168 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31059 times.
✓ Branch 7 taken 2109 times.
9408514 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
11109 2109 removearmos(x,y,ffcactivated);
11110
11111
11112
2/2
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 9406183 times.
9408723 if(hashero)
11113 {
11114 2540 Hero.setX(x);
11115 2540 Hero.setY(y);
11116 2540 ++clk2;
11117
11118
4/4
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2489 times.
✓ Branch 3 taken 51 times.
2540 if(clk2==(dmisc8==0 ? 95 : dmisc8))
11119 {
11120
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
51 switch(dmisc7)
11121 {
11122 case e7tEATITEMS:
11123 {
11124
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<MAXITEMS; i++)
11125 {
11126
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1 times.
256 if(itemsbuf[i].flags&ITEM_EDIBLE)
11127 1 game->set_item(i, false);
11128 256 }
11129
11130 1 break;
11131 }
11132
11133 case e7tEATMAGIC:
11134 game->change_dmagic(-1*game->get_magicdrainrate());
11135 break;
11136
11137 case e7tEATRUPEES:
11138 game->change_drupy(-1);
11139 break;
11140 }
11141
11142 51 clk2=0;
11143 51 }
11144
11145
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 2335 times.
2540 if((clk&0x18)==8) // stop its animation on the middle frame
11146 2335 --clk;
11147 2540 }
11148
4/4
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8706069 times.
✓ Branch 2 taken 408221 times.
✓ Branch 3 taken 291893 times.
9406183 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
11149 {
11150 // Movement engine
11151
4/6
✓ Branch 0 taken 504520 times.
✓ Branch 1 taken 8609770 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8607438 times.
✗ Branch 5 not taken.
9114290 if(clk>=0) switch(id>>12)
11152 {
11153 case 0: // Normal movement
11154
11155 /*
11156 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
11157 {
11158 // Overloading clk4 (Tribble clock) here...
11159 step=17/100.0;
11160 if(clk4<32) misc=1;
11161 else if(clk4<48) misc=2;
11162 else if(clk4<300) { misc=3; step = dstep/100.0; }
11163 else if(clk4<316) misc=2;
11164 else if(clk4<412) misc=1;
11165 else if(clk4<540) { misc=0; step=0; }
11166 else clk4=0;
11167 if(clk4==48) clk=0;
11168 hxofs=(misc>=2)?0:1000;
11169 if (dmisc9==e9tLEEVER)
11170 variable_walk(rate, homing, 0);
11171 else
11172 variable_walk_8(rate, homing, 4, 0);
11173 break;
11174 }
11175 */
11176
4/4
✓ Branch 0 taken 8408380 times.
✓ Branch 1 taken 199058 times.
✓ Branch 2 taken 273002 times.
✓ Branch 3 taken 8135378 times.
8607438 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
11177 {
11178 472060 vire_hop();
11179 472060 break;
11180 }
11181
2/2
✓ Branch 0 taken 649572 times.
✓ Branch 1 taken 7485806 times.
8135378 else if(dmisc9==e9tROPE) //Rope charge
11182 {
11183
9/10
✓ Branch 0 taken 632150 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 89355 times.
✓ Branch 3 taken 542795 times.
✓ Branch 4 taken 80424 times.
✓ Branch 5 taken 8931 times.
✓ Branch 6 taken 79638 times.
✓ Branch 7 taken 786 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79638 times.
649572 if(!fired && dashing && !stunclk && !watch && !frozenclock)
11184 {
11185
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 77266 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
79638 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
11186 {
11187
11188
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
11189 {
11190 14 hp=-1000;
11191
11192
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11193 {
11194
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
11195 14 Ewpns.add(ew);
11196 14 ew->fakez = fakez;
11197
11198
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
11199 {
11200 14 ew->step=0;
11201 14 ew->id=wpn+dmisc3;
11202 14 ew->misc=50;
11203 14 ew->clk=48;
11204 14 }
11205
11206 14 fired=true;
11207 14 }
11208 else
11209 {
11210 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
11211 Ewpns.add(ew);
11212 ew->fakez = fakez;
11213
11214 if(wpn==ewSBomb || wpn==ewBomb)
11215 {
11216 ew->step=0;
11217 ew->id=wpn;
11218 ew->misc=50;
11219 ew->clk=48;
11220 }
11221
11222 fired=true;
11223 }
11224 14 }
11225
11226 else
11227 {
11228 1 hp=-1000;
11229
11230 int32_t wpn2;
11231
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11232 1 wpn2=wpn;
11233 else
11234 wpn2=wpn;
11235
11236
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
11237 1 Ewpns.add(ew);
11238 1 ew->fakez = fakez;
11239
11240
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
11241 {
11242 1 ew->step=0;
11243 1 ew->id=wpn2;
11244 1 ew->misc=50;
11245 1 ew->clk=48;
11246 1 }
11247
11248 1 fired=true;
11249 }
11250 15 }
11251 79638 }
11252
11253 649572 charge_attack();
11254 649572 break;
11255 }
11256 /*
11257 * Boomerang-throwers have a halt count of 1
11258 * Zols have a halt count of (zc_oldrand()&7)<<4
11259 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
11260 * Everything else has 48
11261 */
11262 else
11263 {
11264
2/2
✓ Branch 0 taken 378407 times.
✓ Branch 1 taken 7107399 times.
7485806 if(wpn==ewBrang) // Goriya
11265 {
11266 378407 halting_walk(rate,homing,0,hrate, 1);
11267 378407 }
11268
4/4
✓ Branch 0 taken 7074085 times.
✓ Branch 1 taken 33314 times.
✓ Branch 2 taken 2912329 times.
✓ Branch 3 taken 4161756 times.
7107399 else if(dmisc9==e9tNORMAL && wpn==0)
11269 {
11270
2/2
✓ Branch 0 taken 574887 times.
✓ Branch 1 taken 3586869 times.
4161756 if(dmisc2==e2tSPLITHIT) // Zol
11271 {
11272 574887 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
11273 574887 }
11274
4/4
✓ Branch 0 taken 1147347 times.
✓ Branch 1 taken 2439522 times.
✓ Branch 2 taken 1047903 times.
✓ Branch 3 taken 99444 times.
3586869 else if(frate<=8 && starting_hp==1) // Gel
11275 {
11276 99444 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
11277 99444 }
11278 else // Other
11279 {
11280 3487425 halting_walk(rate,homing,0,hrate, 48);
11281 }
11282 4161756 }
11283 else // Other
11284 {
11285 2945643 halting_walk(rate,homing,0,hrate, 48);
11286 }
11287 }
11288
11289 //if not in midair, and Hero's swinging sword is nearby, jump.
11290 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
11291 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
11292 {
11293 facehero(false);
11294 sclk=16+((dir^1)<<8);
11295 fall=-FEATHERJUMP;
11296 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
11297 }*/
11298 7485806 break;
11299
11300 // Following cases are for just after creation-by-splitting.
11301 case 1:
11302
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 580 times.
2332 if(misc==1)
11303 {
11304 580 dir=up;
11305 580 step=8;
11306 580 }
11307
11308
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 1773 times.
2332 if(misc<=2)
11309 {
11310 1773 move(step);
11311
11312
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 343 times.
1773 if(!canmove(dir,(zfix)0,0,false))
11313 343 dir=down;
11314 1773 }
11315
11316
2/2
✓ Branch 0 taken 1773 times.
✓ Branch 1 taken 559 times.
2332 if(misc==3)
11317 {
11318
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 350 times.
559 if(canmove(right,(zfix)16,0,false))
11319 350 x+=16;
11320 559 }
11321
11322 2332 ++misc;
11323 2332 break;
11324
11325 case 2:
11326 if(misc==1)
11327 {
11328 dir=down;
11329 step=8;
11330 }
11331
11332 if(misc<=2)
11333 {
11334 move(step);
11335 /*
11336 if(!canmove(dir,(zfix)0,0,false))
11337 dir=up;
11338 */
11339 }
11340
11341 if(misc==3)
11342 {
11343 if(canmove(left,(zfix)16,0,false))
11344 x-=16;
11345 }
11346
11347 ++misc;
11348 break;
11349
11350 default:
11351 if(misc==1)
11352 {
11353 dir=(zc_oldrand()%4);
11354 step=8;
11355 }
11356
11357 if(misc<=2)
11358 {
11359 move(step);
11360
11361 if(!canmove(dir,(zfix)0,0,false))
11362 dir=dir^1;
11363 }
11364
11365 if(misc==3)
11366 {
11367 if(dir >= left && canmove(dir,(zfix)16,0,false))
11368 x+=(dir==left ? -16 : 16);
11369 }
11370
11371 ++misc;
11372 break;
11373 8609770 }
11374
11375
4/4
✓ Branch 0 taken 16816 times.
✓ Branch 1 taken 9097474 times.
✓ Branch 2 taken 16257 times.
✓ Branch 3 taken 559 times.
9114290 if(id>>12 && misc>=4) //recently spawned by a split enemy
11376 {
11377 559 id&=0xFFF;
11378 559 step = zslongToFix(dstep*100);
11379
11380
1/2
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
559 if(x<32) x=32;
11381
11382
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 13 times.
559 if(x>208) x=208;
11383
11384
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 18 times.
559 if(y<32) y=32;
11385
11386
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 5 times.
559 if(y>128) y=128;
11387
11388 559 misc=3;
11389 559 }
11390 9114290 }
11391 else
11392 {
11393 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11394
1/2
✓ Branch 0 taken 291893 times.
✗ Branch 1 not taken.
291893 if(clk2>2) clk2--;
11395 }
11396
11397 // Fire Zol
11398
7/8
✓ Branch 0 taken 3944791 times.
✓ Branch 1 taken 5463932 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 3938157 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
9408723 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11399 {
11400 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11401 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
11402
11403 47 int32_t i=Ewpns.Count()-1;
11404 47 weapon *ew = (weapon*)(Ewpns.spr(i));
11405
11406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11407 {
11408 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11409 if ( ew->do_animation ) ew->tile+=ew->aframe;
11410 }
11411 47 }
11412 // Goriya
11413
14/16
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8708562 times.
✓ Branch 2 taken 318261 times.
✓ Branch 3 taken 381853 times.
✓ Branch 4 taken 310952 times.
✓ Branch 5 taken 7309 times.
✓ Branch 6 taken 286403 times.
✓ Branch 7 taken 24549 times.
✓ Branch 8 taken 286403 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283662 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 283662 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 279458 times.
✓ Branch 15 taken 4204 times.
9408676 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11414 {
11415 4204 misc=index+100;
11416
7/14
✓ Branch 0 taken 4204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4204 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4204 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4204 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4204 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4204 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4204 times.
✗ Branch 13 not taken.
4204 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11417 4204 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11418
11419
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 155 times.
4204 if(dmisc1==2)
11420 {
11421 155 int32_t ndir=dir;
11422
11423
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
11424 {
11425 4 ndir=(Hero.y+8<y)?up:down;
11426 4 }
11427 else //turn to face Hero
11428 {
11429 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11430 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11431
11432
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11433 {
11434 9 ndir=down;
11435 9 }
11436
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11437 {
11438 41 ndir=right;
11439 41 }
11440
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11441 {
11442 33 ndir=up;
11443 33 }
11444 else
11445 {
11446 68 ndir=left;
11447 }
11448 }
11449
11450 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11451
11452
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
11453 {
11454 153 dir=ndir;
11455 153 }
11456 155 }
11457 4204 }
11458
15/16
✓ Branch 0 taken 9367609 times.
✓ Branch 1 taken 36863 times.
✓ Branch 2 taken 121574 times.
✓ Branch 3 taken 9282898 times.
✓ Branch 4 taken 106507 times.
✓ Branch 5 taken 15067 times.
✓ Branch 6 taken 91800 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 91114 times.
✓ Branch 9 taken 686 times.
✓ Branch 10 taken 82969 times.
✓ Branch 11 taken 8145 times.
✓ Branch 12 taken 82969 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 82025 times.
9404472 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11459
3/3
✓ Branch 0 taken 16959 times.
✓ Branch 1 taken 64165 times.
✓ Branch 2 taken 901 times.
82025 switch(dmisc1)
11460 {
11461 case e1tCONSTANT: //Deathnut
11462 {
11463 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11464
2/2
✓ Branch 0 taken 62822 times.
✓ Branch 1 taken 1343 times.
64165 if(clk5>64)
11465 {
11466 1343 clk5=0;
11467 1343 fired=false;
11468 1343 }
11469
11470 64165 clk5+=(zc_oldrand()&3);
11471
11472
4/4
✓ Branch 0 taken 39489 times.
✓ Branch 1 taken 24676 times.
✓ Branch 2 taken 13354 times.
✓ Branch 3 taken 26135 times.
64165 if((clk5>24)&&(clk5<52))
11473 {
11474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26135 times.
26135 if ( do_animation )tile+=20; //firing
11475
11476
4/4
✓ Branch 0 taken 14252 times.
✓ Branch 1 taken 11883 times.
✓ Branch 2 taken 12803 times.
✓ Branch 3 taken 1449 times.
26135 if(!fired&&(clk5>=38))
11477 {
11478
5/10
✓ Branch 0 taken 1449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1449 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1449 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1449 times.
✗ Branch 9 not taken.
1449 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11479 1449 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11480 1449 sfx(wpnsfx(wpn),pan(int32_t(x)));
11481 1449 fired=true;
11482 1449 }
11483 26135 }
11484
11485 64165 break;
11486 }
11487
11488 case e1tFIREOCTO: //Fire Octo
11489 901 timer=zc_oldrand()%50+50;
11490 901 break;
11491
11492 default:
11493 16959 FireWeapon();
11494 16959 break;
11495 82025 }
11496
11497 /* Fire again if:
11498 * - clk2 about to run out
11499 * - not already double-firing (dmisc1 is 1)
11500 * - not carrying Hero
11501 * - one in 0xF chance
11502 */
11503
8/10
✓ Branch 0 taken 352788 times.
✓ Branch 1 taken 9055935 times.
✓ Branch 2 taken 3024 times.
✓ Branch 3 taken 349764 times.
✓ Branch 4 taken 3024 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3024 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2830 times.
✓ Branch 9 taken 194 times.
9408723 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11504 {
11505 #if 1
11506 194 newdir(rate, homing, grumble);
11507 #else
11508 dir^=2;
11509 #endif
11510 194 clk2=28;
11511 194 ++multishot;
11512 194 }
11513
11514
2/2
✓ Branch 0 taken 2280564 times.
✓ Branch 1 taken 7128159 times.
9408723 if(clk2==0)
11515 {
11516 7128159 multishot = 0;
11517 7128159 }
11518
11519
2/2
✓ Branch 0 taken 9344606 times.
✓ Branch 1 taken 64117 times.
9408723 if(timer) //Fire Octo
11520 {
11521 64117 clk2=15; //this keeps the octo in place until he's done firing
11522
11523
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
11524 {
11525 15704 FireBreath(false);
11526 15704 }
11527
11528 64117 --timer;
11529 64117 }
11530
11531
2/2
✓ Branch 0 taken 9231894 times.
✓ Branch 1 taken 176829 times.
9408723 if(dmisc2==e2tTRIBBLE)
11532 176829 ++clk4;
11533
11534
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 9406483 times.
✓ Branch 2 taken 607 times.
✓ Branch 3 taken 9408116 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
9408723 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11535 {
11536 607 int32_t kids = guys.Count();
11537 607 int32_t id2=dmisc3;
11538
11539
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 607 times.
1214 for(int32_t i=0; i<dmisc4; i++)
11540 {
11541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
607 if(addenemy(x,y,id2,-24))
11542 {
11543
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(itemguy) // Hand down the carried item
11544 {
11545 guycarryingitem = guys.Count()-1;
11546 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11547 itemguy = false;
11548 }
11549
11550 607 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11551 607 }
11552 607 }
11553
11554
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(hashero)
11555 {
11556 Hero.setEaten(0);
11557 hashero=false;
11558 }
11559
11560 607 stop_bgsfx(index);
11561 607 return true;
11562 }
11563
11564 9408116 return enemy::animate(index);
11565 9630028 }
11566
11567 9950483 void eStalfos::draw(BITMAP *dest)
11568 {
11569 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11570 {
11571 clk4--; //Kludge
11572 return;
11573 }*/
11574
11575 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11576 {
11577 cs = dcset;
11578 }*/
11579 9950483 update_enemy_frame();
11580
11581
7/8
✓ Branch 0 taken 9950341 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 9950341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 9914366 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
9950483 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11582 {
11583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
11584 2890 }
11585
11586 9950483 enemy::draw(dest);
11587 9950483 }
11588
11589 2685346 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11590 {
11591 2685346 int32_t tempy=yofs;
11592
11593 /*
11594 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11595 flip = 0;
11596 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11597 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11598 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11599 yofs+=(((int32_t)y+17)&0xF0)-y;
11600 yofs+=8;
11601 }
11602 */
11603
4/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2666214 times.
✓ Branch 3 taken 19132 times.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11604 {
11605 19132 flip = 0;
11606 19132 int32_t fdiv = frate/4;
11607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19132 times.
19132 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11608
11609
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11610 19132 efrate:((clk>=(frate>>1))?1:0);
11611 19132 shadowtile = wpnsbuf[spr_shadow].tile;
11612
11613
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 if(get_qr(qr_NEWENEMYTILES))
11614 {
11615 19132 shadowtile+=f2;
11616 19132 }
11617 else
11618 {
11619 shadowtile+=f2?1:0;
11620 }
11621
11622 19132 yofs+=shadowdistance;
11623 19132 yofs+=8;
11624 19132 }
11625
3/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2685346 times.
✗ Branch 3 not taken.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11626 {
11627 flip = 0;
11628 int32_t fdiv = frate/4;
11629 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11630
11631 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11632 efrate:((clk>=(frate>>1))?1:0);
11633 shadowtile = wpnsbuf[spr_shadow].tile;
11634
11635 if(get_qr(qr_NEWENEMYTILES))
11636 {
11637 shadowtile+=f2;
11638 }
11639 else
11640 {
11641 shadowtile+=f2?1:0;
11642 }
11643 }
11644
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 2685204 times.
2685346 if(!shadow_overpit(this))
11645 2685204 enemy::drawshadow(dest, translucent);
11646 2685346 yofs=tempy;
11647 2685346 }
11648
11649 98900 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11650 {
11651 98900 int32_t wpnId = w->id;
11652 98900 int32_t wpnDir = w->dir;
11653
11654
4/4
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 98324 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 380 times.
98900 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11655
5/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 77 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 77 times.
196 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
11656
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
11657 {
11658 119 shield = false;
11659 119 flags &= ~(inv_left|inv_right|inv_back|inv_front);
11660
11661
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 14 times.
119 if(get_qr(qr_BRKNSHLDTILES))
11662 14 o_tile=s_tile;
11663 119 }
11664
11665 98900 int32_t ret = enemy::takehit(w,realweap);
11666
11667
4/4
✓ Branch 0 taken 12005 times.
✓ Branch 1 taken 86895 times.
✓ Branch 2 taken 10754 times.
✓ Branch 3 taken 1251 times.
98900 if(sclk && dmisc2==e2tSPLITHIT)
11668 1251 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11669
11670 98900 return ret;
11671 }
11672
11673 649572 void eStalfos::charge_attack()
11674 {
11675
2/2
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 644651 times.
649572 if(slide())
11676 4921 return;
11677
11678
9/12
✓ Branch 0 taken 644651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 644651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 622871 times.
✓ Branch 5 taken 21780 times.
✓ Branch 6 taken 604111 times.
✓ Branch 7 taken 18760 times.
✓ Branch 8 taken 599945 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 599945 times.
644651 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11679 44706 return;
11680
11681
2/2
✓ Branch 0 taken 23890 times.
✓ Branch 1 taken 576055 times.
599945 if(clk3<=0)
11682 {
11683 23890 fix_coords(true);
11684
11685
2/2
✓ Branch 0 taken 6397 times.
✓ Branch 1 taken 17493 times.
23890 if(!dashing)
11686 {
11687 17493 int32_t ldir = lined_up(7,false);
11688
11689
4/4
✓ Branch 0 taken 1774 times.
✓ Branch 1 taken 15719 times.
✓ Branch 2 taken 1497 times.
✓ Branch 3 taken 277 times.
17493 if(ldir!=-1 && canmove(ldir,false))
11690 {
11691 1497 dir=ldir;
11692 1497 dashing=true;
11693 1497 step=zslongToFix(dstep*100)+1;
11694 1497 }
11695 15996 else newdir(4,0,0);
11696 17493 }
11697
11698
2/2
✓ Branch 0 taken 23007 times.
✓ Branch 1 taken 883 times.
23890 if(!canmove(dir,false))
11699 {
11700 883 step=zslongToFix(dstep*100);
11701 883 newdir();
11702 883 dashing=false;
11703 883 }
11704
11705 23890 zfix div = step;
11706
11707
1/2
✓ Branch 0 taken 23890 times.
✗ Branch 1 not taken.
23890 if(div == 0)
11708 div = 1;
11709
11710 23890 clk3=(int32_t)(16.0/div);
11711 23890 return;
11712 }
11713
11714 576055 move(step);
11715 576055 --clk3;
11716 649572 }
11717
11718 472060 void eStalfos::vire_hop()
11719 {
11720 //if ( sclk > 0 ) return; //Don't hop during knockback.
11721
11722 // if(dmisc9!=e9tPOLSVOICE)
11723 // {
11724 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11725 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11726 // return; //the enemy should split if it is sliding!
11727 // //else sclk=0; //might need this here, too. -Z
11728 // }
11729
2/2
✓ Branch 0 taken 199058 times.
✓ Branch 1 taken 273002 times.
472060 if(dmisc9!=e9tPOLSVOICE)
11730 {
11731
2/2
✓ Branch 0 taken 193681 times.
✓ Branch 1 taken 5377 times.
199058 if(sclk!=0)
11732 {
11733
2/2
✓ Branch 0 taken 1534 times.
✓ Branch 1 taken 3843 times.
5377 if (dmisc2==e2tSPLITHIT) return;
11734 //return;
11735 3843 }
11736 197524 }
11737 273002 else sclk=0;
11738
11739
8/12
✓ Branch 0 taken 470526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 462011 times.
✓ Branch 5 taken 8515 times.
✓ Branch 6 taken 446955 times.
✓ Branch 7 taken 15056 times.
✓ Branch 8 taken 446955 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 446955 times.
470526 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11740 23571 return;
11741
11742 446955 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11743 446955 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11744
11745 446955 y=floor_y;
11746
11747
2/2
✓ Branch 0 taken 432185 times.
✓ Branch 1 taken 14770 times.
446955 if(clk3<=0)
11748 {
11749 14770 fix_coords();
11750
11751 //z=0;
11752 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11753 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11754
9/10
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
✓ Branch 2 taken 2542 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2448 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
14770 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
11755 12322 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11756
11757
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
14770 if(clk2<=0)
11758 {
11759 //z=0;
11760
6/6
✓ Branch 0 taken 10893 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 10646 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 7845 times.
✓ Branch 5 taken 2801 times.
11899 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11761 {
11762
11763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9098 times.
9098 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11764 /*if (dmisc9==e9tPOLSVOICE )
11765 {
11766 zprint2("polsvoice jump_width is: %d\n", jump_width);
11767 zprint2("polsvoice raw step is: %d\n", step);
11768 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11769 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11770 }
11771 else
11772 {
11773 zprint2("vire jump_width is: %d\n", jump_width);
11774 zprint2("vire raw step is: %d\n", step);
11775 zprint2("vire step.getInt() is: %d\n", step.getInt());
11776 zprint2("setting clk2 on vire to: %d\n", clk2);
11777 }
11778 */
11779 9098 }
11780 11899 }
11781
11782
4/4
✓ Branch 0 taken 6207 times.
✓ Branch 1 taken 8563 times.
✓ Branch 2 taken 2801 times.
✓ Branch 3 taken 3406 times.
14770 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11783 {
11784 3406 clk2=int32_t((16.0*jump_width)/step.getFloat());
11785 3406 }
11786
11787 14770 clk3=int32_t(16.0/step.getFloat());
11788 14770 }
11789
11790 446955 --clk3;
11791
11792
3/4
✓ Branch 0 taken 185954 times.
✓ Branch 1 taken 261001 times.
✓ Branch 2 taken 185954 times.
✗ Branch 3 not taken.
446955 if(dmisc9==e9tPOLSVOICE || clk2>0)
11793 446955 move(step);
11794
11795 446955 floor_y=y;
11796 446955 clk2--;
11797
11798 //if we're in the middle of a jump
11799
6/6
✓ Branch 0 taken 350625 times.
✓ Branch 1 taken 96330 times.
✓ Branch 2 taken 148718 times.
✓ Branch 3 taken 201907 times.
✓ Branch 4 taken 67317 times.
✓ Branch 5 taken 81401 times.
446955 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11800 {
11801 269224 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11802
11803
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 172140 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
269224 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11804 {
11805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
11806 90933 else z=h;
11807 90933 }
11808 else
11809 {
11810 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11811 //y-=h;
11812 178291 y=floor_y-h;
11813 178291 shadowdistance=h;
11814 }
11815 269224 }
11816 else
11817 177731 shadowdistance = 0;
11818 472060 }
11819
11820 51 void eStalfos::eathero()
11821 {
11822
5/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 32 times.
51 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11823 {
11824 32 hashero=true;
11825 32 y=floor_y;
11826 32 z=0;
11827
11828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(Hero.isSwimming())
11829 {
11830 Hero.setX(x);
11831 Hero.setY(y);
11832 }
11833 else
11834 {
11835 32 x=Hero.getX();
11836 32 y=Hero.getY();
11837 }
11838
11839 32 clk2=0;
11840 32 }
11841 51 }
11842
11843 983776 bool eStalfos::WeaponOut()
11844 {
11845
2/2
✓ Branch 0 taken 1749223 times.
✓ Branch 1 taken 412425 times.
2161648 for(int32_t i=0; i<Ewpns.Count(); i++)
11846 {
11847
3/4
✓ Branch 0 taken 571351 times.
✓ Branch 1 taken 1177872 times.
✓ Branch 2 taken 571351 times.
✗ Branch 3 not taken.
1749223 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11848 {
11849 571351 return true;
11850 }
11851
11852 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11853 stop_sfx(bgsfx);
11854 */
11855 1177872 }
11856
11857 412425 return false;
11858 983776 }
11859
11860 207899 void eStalfos::KillWeapon()
11861 {
11862
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 188444 times.
396343 for(int32_t i=0; i<Ewpns.Count(); i++)
11863 {
11864
4/4
✓ Branch 0 taken 159094 times.
✓ Branch 1 taken 29350 times.
✓ Branch 2 taken 158567 times.
✓ Branch 3 taken 527 times.
188444 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11865 {
11866 //only kill this Goriya's boomerang -DD
11867
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 234 times.
527 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11868 {
11869 234 Ewpns.del(i);
11870 234 }
11871 527 }
11872 188444 }
11873
11874
4/4
✓ Branch 0 taken 17536 times.
✓ Branch 1 taken 190363 times.
✓ Branch 2 taken 8819 times.
✓ Branch 3 taken 8717 times.
207899 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11875 {
11876 8819 stop_sfx(WAV_BRANG);
11877 8819 }
11878 207899 }
11879
11880 void eStalfos::break_shield()
11881 {
11882 if(!shield)
11883 return;
11884
11885 flags&=~(inv_front | inv_back | inv_left | inv_right);
11886 shield=false;
11887
11888 if(get_qr(qr_BRKNSHLDTILES))
11889 o_tile=s_tile;
11890 }
11891
11892 6621 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11893 6621 {
11894
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 dir=(zc_oldrand()&7)+8;
11895
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 step=0;
11896 6621 movestatus=1;
11897
3/4
✓ Branch 0 taken 5596 times.
✓ Branch 1 taken 1025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5596 times.
6621 if (dmisc1 != 1 && dmisc19 > 0)
11898 {
11899 step = dmisc19/100.0;
11900 movestatus = 1;
11901 }
11902
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if (dmisc1 == 2) movestatus=2;
11903 6621 c=0;
11904 6621 SIZEflags = d->SIZEflags;
11905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
11906
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11907
11908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hit_width=12;
11909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
11910
11911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
11912
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11913
11914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hit_height=8;
11915
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
11916
11917
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11918 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
11919 // al_trace("Enemy txsz:%i\n", txsz);
11920
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11921
11922
11923
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
11924
11925
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11927 {
11928 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11929 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11930 }
11931
11932
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11933 6621 clk4=0;
11934 //nets;
11935 6621 dummy_int[1]=0;
11936 6621 }
11937
11938 1835461 bool eKeese::animate(int32_t index)
11939 {
11940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835461 times.
1835461 if(switch_hooked) return enemy::animate(index);
11941
2/4
✓ Branch 0 taken 1835461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1835461 times.
1835461 if(fallclk||drownclk) return enemy::animate(index);
11942
2/2
✓ Branch 0 taken 68910 times.
✓ Branch 1 taken 1766551 times.
1835461 if(dying)
11943 68910 return Dead(index);
11944
11945
2/2
✓ Branch 0 taken 15740 times.
✓ Branch 1 taken 1750811 times.
1766551 if(clk==0)
11946 {
11947 15740 removearmos(x,y,ffcactivated);
11948 15740 }
11949
11950
2/2
✓ Branch 0 taken 382128 times.
✓ Branch 1 taken 1384423 times.
1766551 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11951 {
11952 382128 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11953 382128 }
11954 else
11955 {
11956
1/2
✓ Branch 0 taken 1384423 times.
✗ Branch 1 not taken.
1384423 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11957 1384423 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11958 }
11959
11960
2/2
✓ Branch 0 taken 35781 times.
✓ Branch 1 taken 1730770 times.
1766551 if(dmisc2 == e2tKEESETRIB)
11961 {
11962
3/4
✓ Branch 0 taken 35781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35710 times.
✓ Branch 3 taken 71 times.
35781 if(++clk4==(dmisc20>0?dmisc20:256))
11963 {
11964
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 53 times.
71 if(!m_walkflag(x,y,0, dir))
11965 {
11966 53 int32_t kids = guys.Count();
11967 53 bool success = false;
11968 53 int32_t id2=dmisc3;
11969 53 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11970
11971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(success)
11972 {
11973
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(itemguy) // Hand down the carried item
11974 {
11975 guycarryingitem = guys.Count()-1;
11976 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11977 itemguy = false;
11978 }
11979
11980 53 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11981 53 }
11982
11983 53 stop_bgsfx(index);
11984 53 return true;
11985 }
11986 else
11987 {
11988 18 clk4=0;
11989 }
11990 18 }
11991 35728 }
11992 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11993
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 1247602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1730770 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11994 {
11995
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11996 {
11997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
11998 {
11999 fakez=int32_t(step/zslongToFix(dstep*100));
12000 // Some variance in keese flight heights when away from Hero
12001 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
12002
12003 }
12004 else
12005 {
12006 483168 z=int32_t(step/zslongToFix(dstep*100));
12007 // Some variance in keese flight heights when away from Hero
12008
2/2
✓ Branch 0 taken 392481 times.
✓ Branch 1 taken 90687 times.
483168 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
12009 }
12010 483168 }
12011 else
12012 {
12013 if (moveflags & FLAG_USE_FAKE_Z)
12014 {
12015 fakez=int32_t(step/zslongToFix(dstep*100));
12016 // Some variance in keese flight heights when away from Hero
12017 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12018
12019 }
12020 else
12021 {
12022 z=int32_t(step/zslongToFix(dstep*100));
12023 // Some variance in keese flight heights when away from Hero
12024 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12025 }
12026 }
12027 483168 }
12028
12029 1766498 return enemy::animate(index);
12030 1835461 }
12031
12032 561528 void eKeese::drawshadow(BITMAP *dest, bool translucent)
12033 {
12034 561528 int32_t tempy=yofs;
12035 561528 flip = 0;
12036 561528 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
12037
12038
2/2
✓ Branch 0 taken 214011 times.
✓ Branch 1 taken 347517 times.
561528 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
12039
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 259006 times.
561528 if(!get_qr(qr_ENEMIESZAXIS))
12040 {
12041 259006 yofs+=int32_t(step/zslongToFix(dstep*10));
12042 259006 }
12043
12044
6/6
✓ Branch 0 taken 557934 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 255412 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
561528 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
12045 549864 enemy::drawshadow(dest, translucent);
12046 561528 yofs=tempy;
12047 561528 }
12048
12049 4144206 void eKeese::draw(BITMAP *dest)
12050 {
12051 4144206 update_enemy_frame();
12052 4144206 enemy::draw(dest);
12053 4144206 }
12054
12055 11346 void eWizzrobe::submerge(bool set)
12056 {
12057
2/2
✓ Branch 0 taken 11318 times.
✓ Branch 1 taken 28 times.
11346 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
12058 {
12059 11318 hxofs = set?1000:0;
12060 11318 return;
12061 }
12062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
12063 28 submerged = set;
12064
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
12065 14 hxofs+=1000;
12066 14 else hxofs -= 1000;
12067 11346 }
12068 2150 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12069 2150 {
12070 2150 hxofs = 0;
12071 2150 submerged = false;
12072
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 1230 times.
2150 switch(dmisc1)
12073 {
12074 case 0:
12075 1230 submerge(true);
12076 1230 fading=fade_invisible;
12077 // Set clk to just before the 'reappear' threshold
12078
6/10
✓ Branch 0 taken 1230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 960 times.
✓ Branch 5 taken 270 times.
✓ Branch 6 taken 960 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 270 times.
✗ Branch 9 not taken.
1230 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
12079 1230 break;
12080
12081 default:
12082 920 dir=(loadside==right)?right:left;
12083 920 misc=-3;
12084 920 break;
12085 }
12086
12087 //netst+2880;
12088 2150 charging=false;
12089 2150 firing=false;
12090 2150 fclk=0;
12091
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 1230 times.
2150 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
12092 2150 SIZEflags = d->SIZEflags;
12093
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12094 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12095 // al_trace("Enemy txsz:%i\n", txsz);
12096
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
12098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
12099
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12100
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
12101 {
12102 hxofs = (submerged?hxofs:0)+d->hxofs;
12103 }
12104
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12105 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12106
1/4
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12108 {
12109 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12110 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12111 }
12112
12113
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12114 2150 }
12115
12116 1015605 bool eWizzrobe::animate(int32_t index)
12117 {
12118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1015605 times.
1015605 if(switch_hooked) return enemy::animate(index);
12119
2/4
✓ Branch 0 taken 1015605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1015605 times.
1015605 if(fallclk||drownclk) return enemy::animate(index);
12120
2/2
✓ Branch 0 taken 21786 times.
✓ Branch 1 taken 993819 times.
1015605 if(dying)
12121 {
12122 21786 return Dead(index);
12123 }
12124
12125
2/2
✓ Branch 0 taken 962127 times.
✓ Branch 1 taken 31692 times.
993819 if(clk==0)
12126 {
12127 31692 removearmos(x,y,ffcactivated);
12128 31692 }
12129
12130
2/2
✓ Branch 0 taken 502494 times.
✓ Branch 1 taken 491325 times.
993819 if(dmisc1) // Floating
12131 {
12132 502494 wizzrobe_attack();
12133 502494 }
12134 else // Teleporting
12135 {
12136
5/6
✓ Branch 0 taken 485972 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 483262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
491325 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
12137 {
12138 5353 fading=0;
12139 5353 submerge(false);
12140 5353 solid_update(false);
12141 5353 }
12142
8/8
✓ Branch 0 taken 469803 times.
✓ Branch 1 taken 2887 times.
✓ Branch 2 taken 2507 times.
✓ Branch 3 taken 2430 times.
✓ Branch 4 taken 2393 times.
✓ Branch 5 taken 2075 times.
✓ Branch 6 taken 2001 times.
✓ Branch 7 taken 1876 times.
485972 else switch(clk)
12143 {
12144 case 0:
12145
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2406 times.
2887 if(!dmisc2)
12146 {
12147 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
12148 // but should not appear on dungeon walls.
12149
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 1997 times.
2406 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
12150
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1925 times.
1997 else if (editorflags&ENEMY_FLAG5)
12151 {
12152 //2.10 Windrobe
12153 //randomise location and face Hero
12154 72 int32_t t=0;
12155 72 bool placed=false;
12156
12157
4/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 72 times.
178 while(!placed && t<160)
12158 {
12159
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 55 times.
106 if(isdungeon())
12160 {
12161 51 x=((zc_oldrand()%12)+2)*16;
12162 51 y=((zc_oldrand()%7)+2)*16;
12163 51 }
12164 else
12165 {
12166 55 x=((zc_oldrand()%14)+1)*16;
12167 55 y=((zc_oldrand()%9)+1)*16;
12168 }
12169
12170
6/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 72 times.
184 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12171 {
12172 72 placed=true;
12173 72 }
12174
12175 106 ++t;
12176 }
12177
12178
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 46 times.
72 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12179 {
12180
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5 times.
26 if(y<Hero.getY())
12181 {
12182 21 dir=down;
12183 21 }
12184 else
12185 {
12186 5 dir=up;
12187 }
12188 26 }
12189 else
12190 {
12191
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 25 times.
46 if(x<Hero.getX())
12192 {
12193 25 dir=right;
12194 25 }
12195 else
12196 {
12197 21 dir=left;
12198 }
12199 }
12200
12201
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!placed) // can't place him, he's gone
12202 return true;
12203
12204
12205 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
12206 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
12207 72 }
12208 1925 else place_on_axis(true, dmisc4!=0);
12209 2406 }
12210 else
12211 {
12212 481 int32_t t=0;
12213 481 bool placed=false;
12214
12215
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
12216 {
12217
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
12218 {
12219 624 x=((zc_oldrand()%12)+2)*16;
12220 624 y=((zc_oldrand()%7)+2)*16;
12221 624 }
12222 else
12223 {
12224 17 x=((zc_oldrand()%14)+1)*16;
12225 17 y=((zc_oldrand()%9)+1)*16;
12226 }
12227
12228
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12229 {
12230 481 placed=true;
12231 481 }
12232
12233 641 ++t;
12234 }
12235
12236
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12237 {
12238
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
12239 {
12240 97 dir=down;
12241 97 }
12242 else
12243 {
12244 62 dir=up;
12245 }
12246 159 }
12247 else
12248 {
12249
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
12250 {
12251 166 dir=right;
12252 166 }
12253 else
12254 {
12255 156 dir=left;
12256 }
12257 }
12258
12259
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
12260 return true;
12261 }
12262
12263 2887 fading=fade_flicker;
12264 2887 submerge(false);
12265 2887 solid_update(false);
12266 2887 break;
12267
12268 case 64:
12269 2507 fading=0;
12270 2507 charging=true;
12271 2507 break;
12272
12273 case 73:
12274 2430 charging=false;
12275 2430 firing=40;
12276 2430 break;
12277
12278 case 83:
12279 2393 wizzrobe_attack_for_real();
12280 2393 break;
12281
12282 case 119:
12283 2075 firing=false;
12284 2075 charging=true;
12285 2075 break;
12286
12287 case 128:
12288 2001 fading=fade_flicker;
12289 2001 charging=false;
12290 2001 break;
12291
12292 case 146:
12293 1876 fading=fade_invisible;
12294 1876 submerge(true);
12295 1876 solid_update(false);
12296
12297 [[fallthrough]];
12298 default:
12299
3/4
✓ Branch 0 taken 471679 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 468788 times.
✓ Branch 3 taken 2891 times.
471679 if(clk>=(146+zc_max(0,dmisc5)))
12300 2891 clk=-1;
12301
12302 471679 break;
12303 }
12304 }
12305
12306 993819 return enemy::animate(index);
12307 1015605 }
12308
12309 3874 void eWizzrobe::wizzrobe_attack_for_real()
12310 {
12311
1/2
✓ Branch 0 taken 3874 times.
✗ Branch 1 not taken.
3874 if(wpn==0) // Edited enemies
12312 return;
12313
12314
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 3069 times.
3874 if(dmisc2 == 0) //normal weapon
12315 {
12316 3069 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
12317 3069 sfx(WAV_WAND,pan(int32_t(x)));
12318 3069 }
12319
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 450 times.
805 else if(dmisc2 == 1) // ring of fire
12320 {
12321 355 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12322 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12323 355 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12324 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12325 355 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12326 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12327 355 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12328 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12329 355 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12330 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12331 355 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12332 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12333 355 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12334 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12335 355 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12336 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12337 355 sfx(WAV_FIRE,pan(int32_t(x)));
12338
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 283 times.
355 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
12339 else
12340 {
12341
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
12342 {
12343 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
12344
12345 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
12346 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
12347 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
12348 case ewRock: sfx(51,pan(int32_t(x))); break;
12349 case ewMagic: sfx(32,pan(int32_t(x))); break;
12350 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12351 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12352 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12353 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12354 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
12355 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
12356 case ewWind: sfx(32,pan(int32_t(x))); break;
12357 case ewFlame2: sfx(13,pan(int32_t(x))); break;
12358 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
12359 case ewIce: sfx(44,pan(int32_t(x))); break;
12360 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
12361 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
12362
12363 }
12364 }
12365 355 }
12366
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
12367 {
12368 436 int32_t bc=0;
12369
12370
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
12371 {
12372
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12373 {
12374 2804 ++bc;
12375 2804 }
12376 5394 }
12377
12378
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
12379 {
12380 428 int32_t kids = guys.Count();
12381 428 int32_t bats=(zc_oldrand()%3)+1;
12382
12383
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
12384 {
12385 // Summon bats (or anything)
12386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
12387 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12388 868 }
12389
12390 428 sfx(WAV_FIRE,pan(int32_t(x)));
12391 428 }
12392 436 }
12393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
12394 {
12395
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
12396 {
12397 return;
12398 }
12399
12400 14 int32_t kids = guys.Count();
12401
12402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
12403 {
12404 14 int32_t newguys=(zc_oldrand()%3)+1;
12405 14 bool summoned=false;
12406
12407
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
12408 {
12409 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12410 25 int32_t x2=0;
12411 25 int32_t y2=0;
12412
12413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
12414 {
12415 27 x2=16*((zc_oldrand()%12)+2);
12416 27 y2=16*((zc_oldrand()%7)+2);
12417
12418
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12419 {
12420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12421 {
12422 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
12424 {
12425 ((enemy*)guys.spr(kids+i))->fakez = 64;
12426 ((enemy*)guys.spr(kids+i))->z = 0;
12427 }
12428 25 }
12429
12430 25 summoned=true;
12431 25 break;
12432 }
12433 2 }
12434 25 }
12435
12436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
12437 {
12438 14 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12439 14 }
12440 14 }
12441 14 }
12442 3874 }
12443
12444
12445 502494 void eWizzrobe::wizzrobe_attack()
12446 {
12447
9/12
✓ Branch 0 taken 487591 times.
✓ Branch 1 taken 14903 times.
✓ Branch 2 taken 487591 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 468976 times.
✓ Branch 5 taken 18615 times.
✓ Branch 6 taken 466825 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 466825 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 466825 times.
502494 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12448 35669 return;
12449
12450
3/8
✓ Branch 0 taken 448202 times.
✓ Branch 1 taken 18623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 448202 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
466825 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12451 {
12452 18623 fix_coords();
12453
12454
5/5
✓ Branch 0 taken 2316 times.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 8722 times.
✓ Branch 3 taken 4845 times.
✓ Branch 4 taken 2137 times.
18623 switch(misc)
12455 {
12456 case 1: //walking
12457
2/2
✓ Branch 0 taken 3698 times.
✓ Branch 1 taken 1147 times.
4845 if(!m_walkflag(x,y,spw_door, dir))
12458 1147 misc=0;
12459 else
12460 {
12461 3698 clk3=16;
12462
12463
2/2
✓ Branch 0 taken 3185 times.
✓ Branch 1 taken 513 times.
3698 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12464 {
12465 513 wizzrobe_newdir(0);
12466 513 }
12467 }
12468
12469 4845 break;
12470
12471 case 2: //phasing
12472 {
12473 2137 int32_t jx=x;
12474 2137 int32_t jy=y;
12475 2137 int32_t jdir=-1;
12476
12477
5/5
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 266 times.
2137 switch(zc_oldrand()&7)
12478 {
12479 case 0:
12480 279 jx-=32;
12481 279 jy-=32;
12482 279 jdir=15;
12483 279 break;
12484
12485 case 1:
12486 245 jx+=32;
12487 245 jy-=32;
12488 245 jdir=9;
12489 245 break;
12490
12491 case 2:
12492 264 jx+=32;
12493 264 jy+=32;
12494 264 jdir=11;
12495 264 break;
12496
12497 case 3:
12498 266 jx-=32;
12499 266 jy+=32;
12500 266 jdir=13;
12501 266 break;
12502 }
12503
12504
10/10
✓ Branch 0 taken 1054 times.
✓ Branch 1 taken 1083 times.
✓ Branch 2 taken 940 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 876 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 763 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 633 times.
✓ Branch 9 taken 130 times.
2137 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12505 {
12506 633 misc=3;
12507 633 clk3=32;
12508 633 dir=jdir;
12509 633 break;
12510 }
12511 1504 }
12512 [[fallthrough]];
12513 case 3:
12514 2107 dir&=3;
12515 2107 misc=0;
12516 [[fallthrough]];
12517 case 0:
12518 10829 wizzrobe_newdir(64);
12519 [[fallthrough]];
12520 default:
12521
2/2
✓ Branch 0 taken 11753 times.
✓ Branch 1 taken 1392 times.
13145 if(!canmove(dir,(zfix)1,spw_door,false))
12522 {
12523
2/2
✓ Branch 0 taken 1326 times.
✓ Branch 1 taken 66 times.
1392 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12524 {
12525 1326 misc=1;
12526 1326 clk3=16;
12527 1326 }
12528 else
12529 {
12530 66 wizzrobe_newdir(64);
12531 66 misc=0;
12532 66 clk3=32;
12533 }
12534 1392 }
12535 else
12536 {
12537 11753 clk3=32;
12538 }
12539
12540 13145 break;
12541 }
12542
12543
2/2
✓ Branch 0 taken 16596 times.
✓ Branch 1 taken 2027 times.
18623 if(misc<0)
12544 2027 ++misc;
12545 18623 }
12546
12547 466825 --clk3;
12548
12549
3/3
✓ Branch 0 taken 98770 times.
✓ Branch 1 taken 332655 times.
✓ Branch 2 taken 35400 times.
466825 switch(misc)
12550 {
12551 case 1:
12552 case 3:
12553 98770 step=1;
12554 98770 break;
12555
12556 case 2:
12557 35400 step=0;
12558 35400 break;
12559
12560 default:
12561 332655 step=0.5;
12562 332655 break;
12563
12564 }
12565
12566 466825 move(step);
12567
12568 // if(d->misc1 && misc<=0 && clk3==28)
12569
5/6
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332655 times.
✓ Branch 3 taken 134170 times.
✓ Branch 4 taken 321156 times.
✓ Branch 5 taken 11499 times.
466825 if(dmisc1 && misc<=0 && clk3==28)
12570 {
12571
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 1619 times.
11499 if(dmisc2 != 1)
12572 {
12573
2/2
✓ Branch 0 taken 8754 times.
✓ Branch 1 taken 1126 times.
9880 if(lined_up(8,false) == dir)
12574 {
12575 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12576 // sfx(WAV_WAND,pan(int32_t(x)));
12577 1126 wizzrobe_attack_for_real();
12578 1126 fclk=30;
12579 1126 }
12580 9880 }
12581 else
12582 {
12583
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 355 times.
1619 if((zc_oldrand()%500)>=400)
12584 {
12585 355 wizzrobe_attack_for_real();
12586 355 fclk=30;
12587 355 }
12588 }
12589 11499 }
12590
12591
4/4
✓ Branch 0 taken 287050 times.
✓ Branch 1 taken 179775 times.
✓ Branch 2 taken 2200 times.
✓ Branch 3 taken 284850 times.
466825 if(misc==0 && (zc_oldrand()&127)==0)
12592 2200 misc=2;
12593
12594
4/4
✓ Branch 0 taken 37600 times.
✓ Branch 1 taken 429225 times.
✓ Branch 2 taken 35712 times.
✓ Branch 3 taken 1888 times.
466825 if(misc==2 && clk3==4)
12595 1888 fix_coords();
12596
12597
2/4
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466825 times.
466825 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12598 {
12599
2/2
✓ Branch 0 taken 424649 times.
✓ Branch 1 taken 42176 times.
466825 if(fclk>0)
12600 {
12601 42176 --fclk;
12602 42176 }
12603 466825 }
12604
12605 502494 }
12606
12607 11408 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12608 {
12609 // Wizzrobes shouldn't move to the edge of the screen;
12610 // if they're already there, they should move toward the center
12611
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11404 times.
11408 if(x<32)
12612 4 dir=right;
12613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(x>=224)
12614 dir=left;
12615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(y<32)
12616 dir=down;
12617
1/2
✓ Branch 0 taken 11404 times.
✗ Branch 1 not taken.
11404 else if(y>=144)
12618 dir=up;
12619 else
12620 11404 newdir(4,homing,spw_wizzrobe);
12621 11408 }
12622
12623 1018464 void eWizzrobe::draw(BITMAP *dest)
12624 {
12625 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12626
13/14
✓ Branch 0 taken 512388 times.
✓ Branch 1 taken 506076 times.
✓ Branch 2 taken 428953 times.
✓ Branch 3 taken 83435 times.
✓ Branch 4 taken 53103 times.
✓ Branch 5 taken 459285 times.
✓ Branch 6 taken 52418 times.
✓ Branch 7 taken 685 times.
✓ Branch 8 taken 51661 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 49440 times.
✓ Branch 11 taken 2221 times.
✓ Branch 12 taken 49440 times.
✗ Branch 13 not taken.
1018464 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12627 49440 return;
12628
12629 969024 int32_t tempint=dummy_int[1];
12630 969024 bool tempbool1=dummy_bool[1];
12631 969024 bool tempbool2=dummy_bool[2];
12632 969024 dummy_int[1]=fclk;
12633 969024 dummy_bool[1]=charging;
12634 969024 dummy_bool[2]=firing;
12635 969024 update_enemy_frame();
12636 969024 dummy_int[1]=tempint;
12637 969024 dummy_bool[1]=tempbool1;
12638 969024 dummy_bool[2]=tempbool2;
12639 969024 enemy::draw(dest);
12640 1018464 }
12641
12642 /*********************************/
12643 /********** Bosses ***********/
12644 /*********************************/
12645
12646 139 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12647 139 {
12648 139 fading=fade_flash_die;
12649 //nets+5120;
12650
6/8
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 31 times.
139 if(dir==down&&y>=128)
12651 {
12652 3 dir=up;
12653 3 }
12654
12655
5/8
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41 times.
✗ Branch 7 not taken.
139 if(dir==right&&x>=208)
12656 {
12657 dir=left;
12658 }
12659 139 SIZEflags = d->SIZEflags;
12660
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12661 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12662 // al_trace("Enemy txsz:%i\n", txsz);
12663
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12666
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12667
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12668
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12669 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12672 {
12673 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12674 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12675 }
12676
12677
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12678 139 }
12679
12680 94046 bool eDodongo::animate(int32_t index)
12681 {
12682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94046 times.
94046 if(switch_hooked) return enemy::animate(index);
12683
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 90876 times.
94046 if(dying)
12684 {
12685 3170 return Dead(index);
12686 }
12687
12688
2/2
✓ Branch 0 taken 90462 times.
✓ Branch 1 taken 414 times.
90876 if(clk==0)
12689 {
12690 414 removearmos(x,y,ffcactivated);
12691 414 }
12692
12693
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 82140 times.
90876 if(clk2) // ate a bomb
12694 {
12695
2/2
✓ Branch 0 taken 8645 times.
✓ Branch 1 taken 91 times.
8736 if(--clk2==0)
12696 91 hp-=misc; // store bomb's power in misc
12697 8736 }
12698 else
12699 82140 constant_walk(rate,homing,spw_clipright);
12700
12701 90876 hit_width = (dir<=down) ? 16 : 32;
12702 // hysz = (dir>=left) ? 16 : 32;
12703
12704 90876 return enemy::animate(index);
12705 94046 }
12706
12707 94037 void eDodongo::draw(BITMAP *dest)
12708 {
12709 94037 tile=o_tile;
12710
12711
2/2
✓ Branch 0 taken 2272 times.
✓ Branch 1 taken 91765 times.
94037 if(clk<0)
12712 {
12713 2272 enemy::drawzcboss(dest);
12714 2272 return;
12715 }
12716
12717 91765 update_enemy_frame();
12718 91765 enemy::drawzcboss(dest);
12719
12720
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 54233 times.
91765 if(dummy_int[1]!=0) //additional tiles
12721 {
12722 54233 tile+=dummy_int[1]; //second tile is previous tile
12723 54233 xofs-=16; //new xofs change
12724 54233 enemy::drawzcboss(dest);
12725 54233 xofs+=16;
12726 54233 }
12727
12728 94037 }
12729
12730 6225 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12731 {
12732 6225 int32_t wpnId = w->id;
12733 6225 int32_t power = w->power;
12734 6225 int32_t wpnx = w->x;
12735 6225 int32_t wpny = w->y;
12736
12737
5/12
✓ Branch 0 taken 6225 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6225 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1749 times.
✓ Branch 5 taken 4476 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1749 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
6225 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12738 4476 return 0;
12739
12740
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 1028 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98 times.
1749 switch(wpnId)
12741 {
12742 case wPhantom:
12743 return 0;
12744
12745 case wFire:
12746 case wBait:
12747 case wWhistle:
12748 case wWind:
12749 case wSSparkle:
12750 case wFSparkle:
12751 return 0;
12752
12753 case wLitBomb:
12754 case wLitSBomb:
12755
6/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 91 times.
607 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12756 516 return 0;
12757
12758 91 clk2=96;
12759 91 misc=power;
12760
12761
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(wpnId==wLitSBomb)
12762 3 item_set=isSBOMB100;
12763
12764 91 return 1;
12765
12766 case wBomb:
12767 case wSBomb:
12768
6/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 739 times.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 667 times.
1028 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12769 361 return 0;
12770
12771 667 stunclk=160;
12772 667 misc=wpnId; // store wpnId
12773 667 return 1;
12774
12775 case wSword:
12776
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 67 times.
98 if(stunclk)
12777 {
12778 67 sfx(WAV_EHIT,pan(int32_t(x)));
12779 67 hp=0;
12780 67 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12781 67 fading=0; // don't flash
12782 67 return 1;
12783 }
12784
12785 [[fallthrough]];
12786 default:
12787 47 sfx(WAV_CHINK,pan(int32_t(x)));
12788 47 }
12789
12790 47 return 1;
12791 6225 }
12792
12793 2 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12794 2 {
12795 2 fading=fade_flash_die;
12796 //nets+5180;
12797 2 previous_dir=-1;
12798
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 if(dir==down&&y>=128)
12799 {
12800 dir=up;
12801 }
12802
12803
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
12804 {
12805 dir=left;
12806 }
12807 2 SIZEflags = d->SIZEflags;
12808
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12809 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12810 // al_trace("Enemy txsz:%i\n", txsz);
12811
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12812
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12814
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12815
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12816
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12817 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12818
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12820 {
12821 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12822 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12823 }
12824
12825
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12826 2 }
12827
12828 848 bool eDodongo2::animate(int32_t index)
12829 {
12830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
12831
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
12832 {
12833 36 return Dead(index);
12834 }
12835
12836
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
12837 {
12838 4 removearmos(x,y,ffcactivated);
12839 4 }
12840
12841
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
12842 {
12843
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
12844 2 hp-=misc; // store bomb's power in misc
12845 192 }
12846 else
12847 620 constant_walk(rate,homing,spw_clipbottomright);
12848
12849 812 hit_width = (dir<=down) ? 16 : 32;
12850 812 hit_height = (dir>=left) ? 16 : 32;
12851 812 hxofs=(dir>=left)?-8:0;
12852 812 hyofs=(dir<left)?-8:0;
12853
12854 812 return enemy::animate(index);
12855 848 }
12856
12857 848 void eDodongo2::draw(BITMAP *dest)
12858 {
12859
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
12860 {
12861 30 enemy::drawzcboss(dest);
12862 30 return;
12863 }
12864
12865 818 int32_t tempx=xofs;
12866 818 int32_t tempy=yofs;
12867 818 update_enemy_frame();
12868 818 enemy::drawzcboss(dest);
12869 818 tile+=dummy_int[1]; //second tile change
12870 818 xofs+=dummy_int[2]; //new xofs change
12871 818 yofs+=dummy_int[3]; //new yofs change
12872 818 enemy::drawzcboss(dest);
12873 818 xofs=tempx;
12874 818 yofs=tempy;
12875 848 }
12876
12877 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12878 {
12879 165 int32_t wpnId = w->id;
12880 165 int32_t power = w->power;
12881 165 int32_t wpnx = w->x;
12882 165 int32_t wpny = w->y;
12883
12884
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
12885 145 return 0;
12886
12887
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
12888 {
12889 case wPhantom:
12890 return 0;
12891
12892 case wFire:
12893 case wBait:
12894 case wWhistle:
12895 case wWind:
12896 case wSSparkle:
12897 case wFSparkle:
12898 return 0;
12899
12900 case wLitBomb:
12901 case wLitSBomb:
12902
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
12903 {
12904 case up:
12905 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12906 return 0;
12907
12908 break;
12909
12910 case down:
12911 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12912 return 0;
12913
12914 break;
12915
12916 case left:
12917
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12918 return 0;
12919
12920 2 break;
12921
12922 case right:
12923 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12924 return 0;
12925
12926 break;
12927 }
12928
12929 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12930 // return 0;
12931 2 clk2=96;
12932 2 misc=power;
12933
12934
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
12935 item_set=isSBOMB100;
12936
12937 2 return 1;
12938
12939 case wBomb:
12940 case wSBomb:
12941
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
12942 {
12943 case up:
12944 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12945 return 0;
12946
12947 break;
12948
12949 case down:
12950 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12951 return 0;
12952
12953 break;
12954
12955 case left:
12956
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12957 return 0;
12958
12959 15 break;
12960
12961 case right:
12962 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12963 return 0;
12964
12965 break;
12966 }
12967
12968 15 stunclk=160;
12969 15 misc=wpnId; // store wpnId
12970 15 return 1;
12971
12972 case wSword:
12973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
12974 {
12975 2 sfx(WAV_EHIT,pan(int32_t(x)));
12976 2 hp=0;
12977 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12978 2 fading=0; // don't flash
12979 2 return 1;
12980 }
12981
12982 [[fallthrough]];
12983 default:
12984 1 sfx(WAV_CHINK,pan(int32_t(x)));
12985 1 }
12986
12987 1 return 1;
12988 165 }
12989
12990 76 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12991 76 {
12992 //these are here to bypass compiler warnings about unused arguments
12993
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( !(editorflags & ENEMY_FLAG5) )
12994 {
12995
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 x = dmisc1 ? 64 : 176;
12996
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 y = 64;
12997 76 }
12998 else { x = X; y = Y; }
12999
13000 //nets+5940;
13001
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 33 times.
76 if(get_qr(qr_NEWENEMYTILES))
13002 {
13003 43 }
13004 else
13005 {
13006
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 26 times.
33 if(dmisc1)
13007 {
13008 7 flip=1;
13009 7 }
13010 }
13011
13012
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13013 76 clk3=32;
13014 76 clk2=0;
13015 76 clk4=clk;
13016 76 dir=left;
13017 76 SIZEflags = d->SIZEflags;
13018
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13019 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13020 // al_trace("Enemy txsz:%i\n", txsz);
13021
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13025
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13026
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13027 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13030 {
13031 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13032 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13033 }
13034
13035
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13036 76 }
13037
13038 50824 bool eAquamentus::animate(int32_t index)
13039 {
13040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50824 times.
50824 if(switch_hooked) return enemy::animate(index);
13041
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 49558 times.
50824 if(dying)
13042 1266 return Dead(index);
13043
13044 // fbx=x+((id==eRAQUAM)?4:-4);
13045
2/2
✓ Branch 0 taken 49337 times.
✓ Branch 1 taken 221 times.
49558 if(clk==0)
13046 {
13047 221 removearmos(x,y,ffcactivated);
13048 221 }
13049
13050 49558 fbx=x;
13051
13052 /*
13053 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
13054 {
13055 fbx+=16;
13056 }
13057 */
13058
2/2
✓ Branch 0 taken 49241 times.
✓ Branch 1 taken 317 times.
49558 if(--clk3==0)
13059 {
13060 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
13061 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
13062 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
13063 317 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
13064 317 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
13065 317 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
13066 317 sfx(wpnsfx(wpn),pan(int32_t(x)));
13067 317 }
13068
13069
4/4
✓ Branch 0 taken 15161 times.
✓ Branch 1 taken 34397 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 14907 times.
49558 if(clk3<-80 && !(zc_oldrand()&63))
13070 {
13071 254 clk3=32;
13072 254 }
13073
13074
2/2
✓ Branch 0 taken 48766 times.
✓ Branch 1 taken 792 times.
49558 if(!((clk4+1)&63))
13075 {
13076 792 int32_t d2=(zc_oldrand()%3)+1;
13077
13078
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 533 times.
792 if(d2>=left)
13079 {
13080 533 dir=d2;
13081 533 }
13082
13083
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 442 times.
792 if(dmisc1)
13084 {
13085
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 35 times.
350 if(x<=40)
13086 {
13087 35 dir=right;
13088 35 }
13089
13090
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(x>=104)
13091 {
13092 dir=left;
13093 }
13094 350 }
13095 else
13096 {
13097
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 14 times.
442 if(x<=136)
13098 {
13099 14 dir=right;
13100 14 }
13101
13102
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 22 times.
442 if(x>=200)
13103 {
13104 22 dir=left;
13105 22 }
13106 }
13107 792 }
13108
13109
4/4
✓ Branch 0 taken 48440 times.
✓ Branch 1 taken 1118 times.
✓ Branch 2 taken 42352 times.
✓ Branch 3 taken 6088 times.
49558 if(clk4>=-1 && !((clk4+1)&7))
13110 {
13111
2/2
✓ Branch 0 taken 3226 times.
✓ Branch 1 taken 2862 times.
6088 if(dir==left)
13112 {
13113 3226 x-=1;
13114 3226 }
13115 else
13116 {
13117 2862 x+=1;
13118 }
13119 6088 }
13120
13121 49558 clk4=(clk4+1)%256;
13122
13123 49558 return enemy::animate(index);
13124 50824 }
13125
13126 51235 void eAquamentus::draw(BITMAP *dest)
13127 {
13128
2/2
✓ Branch 0 taken 29751 times.
✓ Branch 1 taken 21484 times.
51235 if(get_qr(qr_NEWENEMYTILES))
13129 {
13130 29751 xofs=(dmisc1?-16:0);
13131
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29751 times.
✓ Branch 2 taken 12244 times.
✓ Branch 3 taken 17507 times.
29751 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
13132
13133
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 29061 times.
29751 if(dying)
13134 {
13135 690 xofs=0;
13136 690 enemy::draw(dest);
13137 690 }
13138 else
13139 {
13140 29061 drawblock(dest,15);
13141 }
13142 29751 }
13143 else
13144 {
13145 21484 int32_t xblockofs=((dmisc1)?-16:16);
13146 21484 xofs=0;
13147
13148
4/4
✓ Branch 0 taken 20982 times.
✓ Branch 1 taken 502 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 20406 times.
21484 if(clk<0 || dying)
13149 {
13150 1078 enemy::draw(dest);
13151 1078 return;
13152 }
13153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20406 times.
20406 if ( do_animation )
13154 {
13155 // face (0=firing, 2=resting)
13156 20406 tile=o_tile+((clk3>0)?0:2);
13157 20406 enemy::draw(dest);
13158 // tail (
13159 20406 tile=o_tile+((clk&16)?1:3);
13160 20406 xofs=xblockofs;
13161 20406 enemy::draw(dest);
13162 // body
13163 20406 yofs+=16;
13164 20406 xofs=0;
13165 20406 tile=o_tile+((clk&16)?20:22);
13166 20406 enemy::draw(dest);
13167 20406 xofs=xblockofs;
13168 20406 tile=o_tile+((clk&16)?21:23);
13169 20406 enemy::draw(dest);
13170 20406 yofs-=16;
13171 20406 }
13172 else enemy::draw(dest);
13173 }
13174 51235 }
13175
13176 10639 bool eAquamentus::hit(weapon *w)
13177 {
13178
3/6
✓ Branch 0 taken 10639 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10639 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10639 times.
10639 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
13179
13180
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 7833 times.
10639 switch(w->id)
13181 {
13182 case wBeam:
13183 case wRefBeam:
13184 case wMagic:
13185 2806 hit_height=32;
13186 2806 }
13187
13188
4/4
✓ Branch 0 taken 10500 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 2202 times.
10639 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
13189 10639 hit_height=16;
13190 10639 return ret;
13191
13192 10639 }
13193
13194 55 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
13195 55 {
13196
13197
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( !(editorflags & ENEMY_FLAG5) )
13198 {
13199
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 x = 128;
13200
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 y = 48;
13201 55 }
13202 else { x = X; y = Y; }
13203
13204 55 Clk=Clk;
13205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(flags & guy_fadeflicker)
13206 {
13207 clk=0;
13208 superman = 1;
13209 fading=fade_flicker;
13210 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
13211 }
13212
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36 times.
55 else if(flags & guy_fadeinstant)
13213 {
13214 36 clk=0;
13215 36 }
13216 55 hxofs=-16;
13217 55 hit_width=48;
13218 55 clk4=0;
13219
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13220
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 dir=zc_oldrand()%3+1;
13221 55 SIZEflags = d->SIZEflags;
13222
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13223 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13224 // al_trace("Enemy txsz:%i\n", txsz);
13225
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
13226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
13227
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
13228
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
13229
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
13230
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
13231 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13232
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
13233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13234 {
13235 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
13236 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13237 }
13238
13239
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
13240
13241 //nets+5340;
13242 55 }
13243
13244 46569 bool eGohma::animate(int32_t index)
13245 {
13246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46569 times.
46569 if(switch_hooked) return enemy::animate(index);
13247
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 45799 times.
46569 if(dying)
13248 770 return Dead(index);
13249
13250
2/2
✓ Branch 0 taken 45788 times.
✓ Branch 1 taken 11 times.
45799 if(fading)
13251 {
13252
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(++clk4 > 60)
13253 {
13254 11 clk4=0;
13255 11 superman=0;
13256 11 fading=0;
13257 11 clk=0;
13258
13259 11 }
13260 else return enemy::animate(index);
13261 11 }
13262
13263
2/2
✓ Branch 0 taken 45583 times.
✓ Branch 1 taken 216 times.
45799 if(clk==0)
13264 {
13265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if (ffcactivated) removearmosffc(ffcactivated-1);
13266 else
13267 {
13268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 removearmos(zc_max(x-16, 0_zf),y);
13269 216 did_armos = false;
13270 216 removearmos(x,y);
13271 216 did_armos = false;
13272
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 removearmos(zc_min(x+16, 255_zf),y);
13273 }
13274 216 }
13275
13276
2/2
✓ Branch 0 taken 45511 times.
✓ Branch 1 taken 288 times.
45799 if(clk<0) return enemy::animate(index);
13277
13278 // Movement clk must be separate from animation clk because of the Clock item
13279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45511 times.
45511 if(!watch)
13280 45511 clk4++;
13281
13282
2/2
✓ Branch 0 taken 44826 times.
✓ Branch 1 taken 685 times.
45511 if((clk4&63)==0)
13283 {
13284
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 327 times.
685 if(clk4&64)
13285 358 dir^=1;
13286 else
13287 327 dir=zc_oldrand()%3+1;
13288 685 }
13289
13290
2/2
✓ Branch 0 taken 44776 times.
✓ Branch 1 taken 735 times.
45511 if((clk&63)==3)
13291 {
13292
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 187 times.
735 switch(dmisc1)
13293 {
13294 case 1:
13295 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
13296 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13297 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
13298 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
13299 187 break;
13300
13301 default:
13302
3/4
✓ Branch 0 taken 548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 463 times.
548 if(dmisc1 != 1 && dmisc1 != 2)
13303 {
13304 463 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13305 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13306 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13307 463 }
13308
13309 548 break;
13310 }
13311 735 }
13312
13313
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 40155 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
45511 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
13314 {
13315
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
13316 {
13317 183 FireBreath(true);
13318 183 }
13319 1392 }
13320
13321
2/2
✓ Branch 0 taken 22736 times.
✓ Branch 1 taken 22775 times.
45511 if(clk4&1)
13322 22775 move((zfix)1);
13323
13324
2/2
✓ Branch 0 taken 45411 times.
✓ Branch 1 taken 100 times.
45511 if(++clk3>=400)
13325 100 clk3=0;
13326
13327 45511 return enemy::animate(index);
13328 46569 }
13329
13330 46567 void eGohma::draw(BITMAP *dest)
13331 {
13332 46567 tile=o_tile;
13333
13334
4/4
✓ Branch 0 taken 46279 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 45509 times.
46567 if(clk<0 || dying)
13335 {
13336 1058 enemy::drawzcboss(dest);
13337 1058 return;
13338 }
13339
13340
2/2
✓ Branch 0 taken 33176 times.
✓ Branch 1 taken 12333 times.
45509 if(get_qr(qr_NEWENEMYTILES))
13341 {
13342 ///if ( do_animation )
13343 //Yuck. Gohma can just not have this capability right now.
13344 // left side
13345 33176 xofs=-16;
13346 33176 flip=0;
13347 // if(clk&16) tile=180;
13348 // else { tile=182; flip=1; }
13349 33176 tile+=(3*((clk&48)>>4));
13350 33176 enemy::drawzcboss(dest);
13351
13352 // right side
13353 33176 xofs=16;
13354 // tile=(180+182)-tile;
13355 33176 tile=o_tile;
13356 33176 tile+=(3*((clk&48)>>4))+2;
13357 33176 enemy::drawzcboss(dest);
13358
13359 // body
13360 33176 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
13361 33176 tile=o_tile;
13362
13363 // tile+=(3*((clk&24)>>3))+2;
13364
2/2
✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 31417 times.
33176 if(clk3<16)
13365 1759 tile+=7;
13366
2/2
✓ Branch 0 taken 9419 times.
✓ Branch 1 taken 21998 times.
31417 else if(clk3<116)
13367 9419 tile+=10;
13368
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
13369 1315 tile+=7;
13370 else
13371 20683 tile+=((clk3-132)&24)?4:1;
13372
13373 33176 enemy::drawzcboss(dest);
13374
13375 33176 }
13376 else
13377 {
13378 // left side
13379 12333 xofs=-16;
13380 12333 flip=0;
13381
13382
2/2
✓ Branch 0 taken 6107 times.
✓ Branch 1 taken 6226 times.
12333 if(!(clk&16))
13383 {
13384 6226 tile+=2;
13385 6226 flip=1;
13386 6226 }
13387
13388 12333 enemy::draw(dest);
13389
13390 // right side
13391 12333 tile=o_tile;
13392 12333 xofs=16;
13393
13394
2/2
✓ Branch 0 taken 6226 times.
✓ Branch 1 taken 6107 times.
12333 if((clk&16)) tile+=2;
13395
13396 // tile=(180+182)-tile;
13397 12333 enemy::draw(dest);
13398
13399 // body
13400 12333 tile=o_tile;
13401 12333 xofs=0;
13402
13403
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 11613 times.
12333 if(clk3<16)
13404 720 tile+=4;
13405
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 7729 times.
11613 else if(clk3<116)
13406 3884 tile+=5;
13407
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7256 times.
7729 else if(clk3<132)
13408 473 tile+=4;
13409 7256 else tile+=((clk3-132)&8)?3:1;
13410
13411 12333 enemy::draw(dest);
13412
13413 }
13414 46567 }
13415
13416 230 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13417 {
13418 230 int32_t wpnId = w->id;
13419 230 int32_t power = w->power;
13420 230 int32_t wpnx = w->x;
13421 230 int32_t wpnDir = w->dir;
13422 230 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13423
13424
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 108 times.
230 if(def < 0)
13425 {
13426
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 13 times.
108 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13427 {
13428 41 sfx(WAV_CHINK,pan(int32_t(x)));
13429 41 return 1;
13430 }
13431 67 }
13432
13433 189 return enemy::takehit(w, realweap);
13434 230 }
13435
13436 198 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13437 198 {
13438 198 count_enemy=(id==(id&0xFFF));
13439 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13440 198 SIZEflags = d->SIZEflags;
13441
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13442 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13443 // al_trace("Enemy txsz:%i\n", txsz);
13444
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13448
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13449
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13450 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13451
1/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13453 {
13454 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13455 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13456 }
13457
13458
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13459 198 }
13460
13461 75067 bool eLilDig::animate(int32_t index)
13462 {
13463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75067 times.
75067 if(switch_hooked) return enemy::animate(index);
13464
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 72061 times.
75067 if(dying)
13465 3006 return Dead(index);
13466
13467
2/2
✓ Branch 0 taken 4113 times.
✓ Branch 1 taken 67948 times.
72061 if(clk==0)
13468 {
13469 4113 removearmos(x,y,ffcactivated);
13470 4113 }
13471
13472
2/2
✓ Branch 0 taken 48439 times.
✓ Branch 1 taken 23622 times.
72061 if(misc<=128)
13473 {
13474
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 22911 times.
23622 if(!(++misc&31))
13475 711 step+=0.25;
13476 23622 }
13477
13478 72061 variable_walk_8(rate,homing,hrate,spw_floater);
13479 72061 return enemy::animate(index);
13480 75067 }
13481
13482 74914 void eLilDig::draw(BITMAP *dest)
13483 {
13484 74914 tile = o_tile;
13485 // tile = 160;
13486 74914 int32_t fdiv = frate/4;
13487
1/2
✓ Branch 0 taken 74914 times.
✗ Branch 1 not taken.
74914 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13488
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13489 74914 efrate:((clk>=(frate>>1))?1:0);
13490
13491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74914 times.
74914 if ( do_animation )
13492 {
13493
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 if(get_qr(qr_NEWENEMYTILES))
13494 {
13495
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5312 times.
✓ Branch 8 taken 5035 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
13496 {
13497 case up: //u
13498 5853 flip=0;
13499 5853 break;
13500
13501 case l_up: //d
13502 5465 flip=0;
13503 5465 tile+=4;
13504 5465 break;
13505
13506 case l_down: //l
13507 5245 flip=0;
13508 5245 tile+=8;
13509 5245 break;
13510
13511 case left: //r
13512 5717 flip=0;
13513 5717 tile+=12;
13514 5717 break;
13515
13516 case r_down: //ul
13517 5242 flip=0;
13518 5242 tile+=20;
13519 5242 break;
13520
13521 case down: //ur
13522 4505 flip=0;
13523 4505 tile+=24;
13524 4505 break;
13525
13526 case r_up: //dl
13527 3937 flip=0;
13528 3937 tile+=28;
13529 3937 break;
13530
13531 case right: //dr
13532 5035 flip=0;
13533 5035 tile+=32;
13534 5035 break;
13535 }
13536
13537 46311 tile+=f2;
13538 46311 }
13539 else
13540 {
13541 28603 tile+=(clk>=6)?1:0;
13542 }
13543 74914 }
13544
13545 74914 enemy::draw(dest);
13546 74914 }
13547
13548 52 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13549 52 {
13550 52 superman=1;
13551
13552 52 SIZEflags = d->SIZEflags;
13553
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13554 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13555 // al_trace("Enemy txsz:%i\n", txsz);
13556
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13558 52 else hit_width=32;
13559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13560 52 else hit_height=32;
13561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13562 52 else hzsz=16; // hard to jump.
13563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13564 52 else hxofs=-8;
13565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13566 52 else hyofs=-8;
13567 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13568
1/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13570 {
13571 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13572 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13573 }
13574
13575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13576
13577
13578 52 }
13579
13580 22457 bool eBigDig::animate(int32_t index)
13581 {
13582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(switch_hooked) return enemy::animate(index);
13583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(dying)
13584 return Dead(index);
13585
13586
2/2
✓ Branch 0 taken 19263 times.
✓ Branch 1 taken 3194 times.
22457 if(clk==0)
13587 {
13588 3194 removearmos(x,y,ffcactivated);
13589 3194 }
13590
13591
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22369 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 44 times.
22457 switch(misc)
13592 {
13593 case 0:
13594 22369 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13595 22369 break;
13596
13597 case 1:
13598 44 ++misc;
13599 44 break;
13600
13601 case 2:
13602
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 44 times.
149 for(int32_t i=0; i<dmisc5; i++)
13603 {
13604 105 addenemy(x,y,dmisc1+0x1000,-15);
13605 105 }
13606
13607
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc6; i++)
13608 {
13609 16 addenemy(x,y,dmisc2+0x1000,-15);
13610 16 }
13611
13612
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc7; i++)
13613 {
13614 16 addenemy(x,y,dmisc3+0x1000,-15);
13615 16 }
13616
13617
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc8; i++)
13618 {
13619 16 addenemy(x,y,dmisc4+0x1000,-15);
13620 16 }
13621
13622
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1 times.
44 if(itemguy) // Hand down the carried item
13623 {
13624 1 guycarryingitem = guys.Count()-1;
13625 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13626 1 itemguy = false;
13627 1 }
13628
13629 44 stop_bgsfx(index);
13630
13631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13632
13633 44 return true;
13634 }
13635
13636 22413 return enemy::animate(index);
13637 22457 }
13638
13639 22452 void eBigDig::draw(BITMAP *dest)
13640 {
13641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if(anim!=aDIG)
13642 {
13643 update_enemy_frame();
13644 xofs-=8;
13645 yofs-=8;
13646 drawblock(dest,15);
13647 xofs+=8;
13648 yofs+=8;
13649 return;
13650 }
13651
13652 22452 tile = o_tile;
13653 22452 int32_t fdiv = frate/4;
13654
1/2
✓ Branch 0 taken 22452 times.
✗ Branch 1 not taken.
22452 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13655
13656
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13657 22452 efrate:((clk>=(frate>>1))?1:0);
13658
13659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if ( do_animation )
13660 {
13661
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 if(get_qr(qr_NEWENEMYTILES))
13662 {
13663
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
13664 {
13665 case up: //u
13666 1115 flip=0;
13667 1115 break;
13668
13669 case l_up: //d
13670 1221 flip=0;
13671 1221 tile+=8;
13672 1221 break;
13673
13674 case l_down: //l
13675 1344 flip=0;
13676 1344 tile+=40;
13677 1344 break;
13678
13679 case left: //r
13680 1195 flip=0;
13681 1195 tile+=48;
13682 1195 break;
13683
13684 case r_down: //ul
13685 1233 flip=0;
13686 1233 tile+=80;
13687 1233 break;
13688
13689 case down: //ur
13690 1223 flip=0;
13691 1223 tile+=88;
13692
13693 1223 break;
13694
13695 case r_up: //dl
13696 993 flip=0;
13697 993 tile+=120;
13698 993 break;
13699
13700 case right: //dr
13701 1450 flip=0;
13702 1450 tile+=128;
13703 1450 break;
13704 }
13705
13706 10238 tile+=(f2*2);
13707 10238 }
13708 else
13709 {
13710 12214 tile+=(f2)?0:2;
13711 12214 flip=(clk&1)?1:0;
13712 }
13713 22452 }
13714
13715 22452 xofs-=8;
13716 22452 yofs-=8;
13717 22452 drawblock(dest,15);
13718 22452 xofs+=8;
13719 22452 yofs+=8;
13720 22452 }
13721
13722 740 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13723 {
13724 740 int32_t wpnId = w->id;
13725
13726
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
740 if(wpnId==wWhistle && misc==0)
13727 44 misc=1;
13728
13729 740 return 0;
13730 }
13731
13732 /*
13733 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13734 {
13735 hxofs=hyofs=8;
13736 hzsz=16; //can't be jumped.
13737 clk2=70;
13738 misc=-1;
13739 mainguy=!getmapflag();
13740 }
13741
13742 bool eGanon::animate(int32_t index)
13743 {
13744 if(switch_hooked) return enemy::animate(index);
13745 if(dying)
13746
13747 return Dead(index);
13748
13749 if(clk==0)
13750 {
13751 removearmos(x,y,ffcactivated);
13752 }
13753
13754 switch(misc)
13755 {
13756 case -1:
13757 misc=0;
13758
13759 case 0:
13760 if(++clk2>72 && !(zc_oldrand()&3))
13761 {
13762 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13763 sfx(wpnsfx(wpn),pan(int32_t(x)));
13764 clk2=0;
13765 }
13766
13767 Stunclk=0;
13768 constant_walk(rate,homing,spw_none);
13769 break;
13770
13771 case 1:
13772 case 2:
13773 if(--Stunclk<=0)
13774 {
13775 int32_t r=zc_oldrand();
13776
13777 if(r&1)
13778 {
13779 y=96;
13780
13781 if(r&2)
13782 x=160;
13783 else
13784 x=48;
13785
13786 if(tooclose(x,y,48))
13787 x=208-x;
13788 }
13789
13790 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13791 //{
13792 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13793 // }
13794 // else
13795 // {
13796 loadpalset(csBOSS,pSprite(d->bosspal));
13797 // }
13798 misc=0;
13799 }
13800
13801 break;
13802
13803 case 3:
13804 {
13805 if(hclk>0)
13806 break;
13807
13808 misc=4;
13809 clk=0;
13810 hxofs=1000;
13811 loadpalset(9,pSprite(spPILE));
13812 music_stop();
13813 stop_sfx(WAV_ROAR);
13814
13815 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13816
13817 sfx(WAV_GANON);
13818 //Ganon's dustpile; fall in sideview. -Z
13819 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13820 dustpile->linked_parent = eeGANON;
13821 setmapflag();
13822 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13823 break;
13824 }
13825
13826 case 4:
13827 if(clk>=80)
13828 {
13829 misc=5;
13830
13831 if(getmapflag())
13832 {
13833 game->lvlitems[dlevel]|=liBOSS;
13834 //play_DmapMusic();
13835 playLevelMusic();
13836 return true;
13837 }
13838
13839 sfx(WAV_CLEARED);
13840 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13841 setmapflag();
13842 }
13843
13844 break;
13845 }
13846
13847 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13848 //{
13849 //if ( current_item_id(itype_amulet,false) >= 2 )
13850 //{
13851 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13852 //}
13853 //}
13854
13855
13856 return enemy::animate(index);
13857 }
13858
13859
13860 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13861 {
13862 //these are here to bypass compiler warnings about unused arguments
13863 int32_t wpnId = w->id;
13864 int32_t power = w->power;
13865 int32_t enemyHitWeapon = w->parentitem;
13866
13867 switch(misc)
13868 {
13869 case 0:
13870 {
13871 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13872 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13873 return 0;
13874
13875 //if we are not using the new defences, just reduce his HP
13876 if (!(editorflags & ENEMY_FLAG14))
13877 {
13878 hp-=power;
13879 if(hp>0)
13880 {
13881 misc=1;
13882 Stunclk=64;
13883 }
13884 else
13885 {
13886 loadpalset(csBOSS,pSprite(spBROWN));
13887 misc=2;
13888 Stunclk=284;
13889 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13890 }
13891
13892 sfx(WAV_EHIT,pan(int32_t(x)));
13893
13894 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13895
13896 return 1;
13897 }
13898 //otherwise, resolve his defence.
13899 else
13900 {
13901 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13902 if(hp>0)
13903 {
13904 misc=1;
13905 Stunclk=64;
13906 }
13907 else
13908 {
13909 loadpalset(csBOSS,pSprite(spBROWN));
13910 misc=2;
13911 Stunclk=284;
13912 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13913 }
13914
13915 sfx(WAV_EHIT,pan(int32_t(x)));
13916
13917 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13918
13919
13920 return 1;
13921 }
13922 }
13923 case 2:
13924 {
13925 if
13926 (
13927 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13928 || //or nothing specified, use silver arrows+
13929 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13930 )
13931 return 0;
13932 {
13933 misc=3;
13934 hclk=81;
13935 loadpalset(9,pSprite(spBROWN));
13936 return 1;
13937 }
13938
13939 }
13940 }
13941
13942 return 0;
13943 }
13944
13945 void eGanon::draw(BITMAP *dest)
13946 {
13947 switch(misc)
13948 {
13949 case 0:
13950 if((clk&3)==3)
13951 tile=(zc_oldrand()%5)*2+o_tile;
13952
13953 if(db!=999)
13954 break;
13955
13956 case 2:
13957 if(Stunclk<64 && (Stunclk&1) )
13958 {
13959 if
13960 (
13961 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13962 ||
13963 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13964 )
13965 {
13966 goto ganon_draw; //draw his weapons if we can see him
13967 }
13968 break;
13969 }
13970
13971 case -1:
13972 tile=o_tile;
13973
13974 //fall through
13975 case 1:
13976 case 3:
13977 ganon_draw:
13978 drawblock(dest,15);
13979 break;
13980
13981 case 4:
13982 draw_guts(dest);
13983 draw_flash(dest);
13984 break;
13985 }
13986
13987 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13988 {
13989 if
13990 (
13991 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13992 ||
13993 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13994 )
13995 {
13996 draw_guts(dest); //makes his shots visible, but not him
13997 draw_flash(dest);
13998 }
13999 }
14000 }
14001
14002 void eGanon::draw_guts(BITMAP *dest)
14003 {
14004 int32_t c = zc_min(clk>>3,8);
14005 tile = clk<24 ? 74 : 75;
14006 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14007 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14008 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14009 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14010 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14011 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14012 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14013 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14014 }
14015
14016 void eGanon::draw_flash(BITMAP *dest)
14017 {
14018
14019 int32_t c = clk-(clk>>2);
14020 cs = (frame&3)+6;
14021 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14022 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14023 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14024 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14025 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14026 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14027 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14028 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14029 }
14030 */
14031
14032 10 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14033 10 {
14034 10 hxofs=hyofs=8;
14035
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (editorflags & ENEMY_FLAG3)
14036 {
14037 hxofs = 4;
14038 hyofs = 4;
14039 hit_width = 24;
14040 hit_height = 24;
14041 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
14042 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
14043 }
14044 10 hzsz=16; //can't be jumped.
14045 10 clk2=70;
14046 10 misc=-1;
14047
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
14048 10 }
14049
14050 15877 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
14051 {
14052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15877 times.
15877 if(dying)
14053
14054 return Dead(index);
14055
14056
2/2
✓ Branch 0 taken 15814 times.
✓ Branch 1 taken 63 times.
15877 if(clk==0)
14057 {
14058 63 removearmos(x,y,ffcactivated);
14059 63 }
14060
14061
6/7
✓ Branch 0 taken 2935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11467 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 738 times.
✓ Branch 5 taken 720 times.
✓ Branch 6 taken 7 times.
15877 switch(misc)
14062 {
14063 case -1:
14064 10 misc=0;
14065 [[fallthrough]];
14066 case 0:
14067
4/4
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 10850 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 156 times.
11477 if(++clk2>72 && !(zc_oldrand()&3))
14068 {
14069 156 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14070 156 sfx(wpnsfx(wpn),pan(int32_t(x)));
14071 156 clk2=0;
14072 156 }
14073
14074 11477 Stunclk=0;
14075 11477 constant_walk(rate,homing,spw_none);
14076 11477 break;
14077
14078 case 1:
14079 case 2:
14080
2/2
✓ Branch 0 taken 2901 times.
✓ Branch 1 taken 34 times.
2935 if(--Stunclk<=0)
14081 {
14082 34 int32_t r=zc_oldrand();
14083
14084
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 14 times.
34 if(r&1)
14085 {
14086 14 y=96;
14087
14088
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 if(r&2)
14089 6 x=160;
14090 else
14091 8 x=48;
14092
14093
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
14 if(tooclose(x,y,48))
14094 6 x=208-x;
14095 14 }
14096
14097 34 loadpalset(csBOSS,pSprite(d->bosspal));
14098 34 misc=0;
14099 34 }
14100
14101 2935 break;
14102
14103 case 3:
14104 {
14105
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 9 times.
738 if(hclk>0)
14106 729 break;
14107
14108 9 misc=4;
14109 9 clk=0;
14110 9 hxofs=1000;
14111 9 loadpalset(9,pSprite(spPILE));
14112 9 music_stop();
14113 9 stop_sfx(WAV_ROAR);
14114
14115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
14116
14117 9 sfx(WAV_GANON);
14118 //Ganon's dustpile; fall in sideview. -Z
14119 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
14120 //dustpile->miscellaneous[31] = eeGANON;
14121
6/12
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
9 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14122 9 item *dustpile = NULL;
14123 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
14124 9 dustpile = (item *)items.spr(items.Count() - 1);
14125 9 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
14126 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
14127 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14128 9 break;
14129 }
14130
14131 case 4:
14132
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 9 times.
720 if(clk>=80)
14133 {
14134 9 misc=5;
14135
14136 //game->lvlitems[dlevel]|=liBOSS;
14137
14138 9 sfx(WAV_CLEARED);
14139 //Add the big TF over the ashes!
14140
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for(word q = 0; q < items.Count(); q++)
14141 {
14142 18 item *ashes = (item*)items.spr(q);
14143
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
18 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
14144 {
14145 //Z_scripterrlog("Found correct dustpile!\n");
14146
4/8
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
9 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
14147 9 item *bigtriforce = NULL;
14148 9 bigtriforce = (item *)items.spr(items.Count() - 1);
14149 9 bigtriforce->linked_parent = eeGANON;
14150 9 }
14151 18 }
14152 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14153 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
14154 9 }
14155
14156 720 break;
14157 7 case 5: return true;
14158 }
14159
14160 15870 return enemy::animate(index);
14161 15877 }
14162
14163
14164 803 int32_t eGanon::takehit(weapon *w, weapon* realweap)
14165 {
14166 //these are here to bypass compiler warnings about unused arguments
14167 803 int32_t wpnId = w->id;
14168 803 int32_t power = w->power;
14169 803 int32_t enemyHitWeapon = w->parentitem;
14170
14171
3/3
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 125 times.
803 switch(misc)
14172 {
14173 case 0:
14174
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 43 times.
74 if(wpnId!=wSword)
14175 31 return 0;
14176
14177 43 hp-=power;
14178
14179
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 9 times.
43 if(hp>0)
14180 {
14181 34 misc=1;
14182 34 Stunclk=64;
14183 34 }
14184 else
14185 {
14186 9 loadpalset(csBOSS,pSprite(spBROWN));
14187 9 misc=2;
14188 9 Stunclk=284;
14189 9 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
14190 }
14191
14192 43 sfx(WAV_EHIT,pan(int32_t(x)));
14193
14194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
14195
14196 43 return 1;
14197
14198 case 2:
14199
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
125 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
14200 116 return 0;
14201
14202 9 misc=3;
14203 9 hclk=81;
14204 9 loadpalset(9,pSprite(spBROWN));
14205 9 return 1;
14206 }
14207
14208 604 return 0;
14209 803 }
14210
14211 17817 void eGanon::draw(BITMAP *dest)
14212 {
14213
6/6
✓ Branch 0 taken 2914 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 759 times.
✓ Branch 3 taken 1950 times.
✓ Branch 4 taken 11467 times.
✓ Branch 5 taken 720 times.
17817 switch(misc)
14214 {
14215 case 0:
14216
2/2
✓ Branch 0 taken 8601 times.
✓ Branch 1 taken 2866 times.
11467 if((clk&3)==3)
14217 2866 tile=(zc_oldrand()%5)*2+o_tile;
14218
14219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
14220 {
14221
14222 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14223 {
14224 int odraw = drawstyle;
14225 drawstyle = 2;
14226 drawblock(dest,15);
14227 drawstyle = odraw;
14228 }
14229 else
14230 {
14231 drawblock(dest,15);
14232 }
14233 break;
14234
14235 }
14236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
14237 {
14238 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14239 {
14240 int odraw = drawstyle;
14241 drawstyle = 2;
14242 drawblock(dest,15);
14243 drawstyle = odraw;
14244 }
14245 else
14246 {
14247 drawblock(dest,15);
14248 }
14249 break;
14250 }
14251
1/2
✓ Branch 0 taken 11467 times.
✗ Branch 1 not taken.
11467 if(db!=999)
14252 11467 break;
14253 [[fallthrough]];
14254 case 2:
14255
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if(Stunclk<64 && (Stunclk&1))
14256 break;
14257 [[fallthrough]];
14258 case -1:
14259 2709 tile=o_tile;
14260
14261 [[fallthrough]];
14262 case 1:
14263 case 3:
14264 5623 drawblock(dest,15);
14265 5623 break;
14266
14267 case 4:
14268 720 draw_guts(dest);
14269 720 draw_flash(dest);
14270 720 break;
14271 }
14272 17817 }
14273
14274 720 void eGanon::draw_guts(BITMAP *dest)
14275 {
14276
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 153 times.
720 int32_t c = zc_min(clk>>3,8);
14277 720 tile = clk<24 ? 74 : 75;
14278 720 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14279 720 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14280 720 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14281 720 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14282 720 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14283 720 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14284 720 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14285 720 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14286 720 }
14287
14288 720 void eGanon::draw_flash(BITMAP *dest)
14289 {
14290
14291 720 int32_t c = clk-(clk>>2);
14292 720 cs = (frame&3)+6;
14293 720 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14294 720 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14295 720 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14296 720 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14297 720 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14298 720 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14299 720 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14300 720 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14301 720 }
14302
14303 8 void getBigTri(int32_t id2)
14304 {
14305 /*
14306 *************************
14307 * BIG TRIFORCE SEQUENCE *
14308 *************************
14309 0 BIGTRI out, WHITE flash in
14310 4 WHITE flash out, PILE cset white
14311 8 WHITE in
14312 ...
14313 188 WHITE out
14314 191 PILE cset red
14315 200 top SHUTTER opens
14316 209 bottom SHUTTER opens
14317 */
14318 8 sfx(itemsbuf[id2].playsound);
14319 8 guys.clear();
14320
14321
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
14322 {
14323 game->lvlitems[dlevel]|=liTRIFORCE;
14324 }
14325
14326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14327
14328 8 draw_screen(tmpscr);
14329
14330
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1536 times.
1544 for(int32_t f=0; f<24*8 && !Quit; f++)
14331 {
14332
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==4)
14333 {
14334
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 8 times.
128 for(int32_t i=1; i<16; i++)
14335 {
14336 120 RAMpal[CSET(9)+i]=_RGB(63,63,63);
14337 120 }
14338 8 }
14339
14340
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==0)
14341 {
14342
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t cs=2; cs<5; cs++)
14343 {
14344
2/2
✓ Branch 0 taken 8640 times.
✓ Branch 1 taken 576 times.
9216 for(int32_t i=1; i<16; i++)
14345 {
14346 8640 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
14347 8640 }
14348 576 }
14349
14350 192 refreshpal=true;
14351 192 }
14352
14353
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==4)
14354 {
14355
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
14356 else loadlvlpal(0xB);
14357 192 }
14358
14359
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==191)
14360 {
14361 8 loadpalset(9,pSprite(spPILE));
14362 8 }
14363
14364 1536 advanceframe(true);
14365 1536 }
14366
14367 //play_DmapMusic();
14368 8 playLevelMusic();
14369
14370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
14371 {
14372 Hero.dowarp(1,0); //side warp
14373 }
14374 8 }
14375
14376 /**********************************/
14377 /*** Multiple-Segment Enemies ***/
14378 /**********************************/
14379
14380
14381 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
14382 94 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14383 94 {
14384
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if( !(editorflags & ENEMY_FLAG5) )
14385 {
14386
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x=128;
14387
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y=48;
14388 94 }
14389 //else { x = X; y = Y; }
14390
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 dir=(zc_oldrand()&7)+8;
14391 94 superman=1;
14392 94 fading=fade_invisible;
14393 94 hxofs=1000;
14394 94 segcnt=clk;
14395 94 segid=Id|0x1000;
14396 94 clk=0;
14397
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 id=guys.Count();
14398
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
94 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14399 94 tile=o_tile;
14400 94 hitdir = -1;
14401 94 stickclk = 0;
14402
14403 /*
14404 if (get_qr(qr_NEWENEMYTILES))
14405 {
14406 tile=nets+1220;
14407 }
14408 else
14409 {
14410 tile=57;
14411 }
14412 */
14413 94 }
14414
14415 86130 bool eMoldorm::animate(int32_t index)
14416 {
14417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(switch_hooked) return enemy::animate(index);
14418 86130 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14419
2/2
✓ Branch 0 taken 66843 times.
✓ Branch 1 taken 19287 times.
86130 if ( y > (max_y) )
14420 {
14421 19287 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14422 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14423 19287 }
14424
2/2
✓ Branch 0 taken 85736 times.
✓ Branch 1 taken 394 times.
86130 if ( stickclk > 45 )
14425 {
14426 394 stickclk = 0;
14427 394 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14428 394 }
14429
14430
14431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(clk==0)
14432 {
14433 86130 removearmos(x,y,ffcactivated);
14434 86130 }
14435
14436
2/2
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 84876 times.
86130 if(clk2)
14437 {
14438
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 66 times.
1254 if(--clk2 == 0)
14439 {
14440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(flags&guy_neverret)
14441 66 never_return(index);
14442
14443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14444 66 leave_item();
14445
14446 66 stop_bgsfx(index);
14447 66 return true;
14448 }
14449 1188 }
14450 else
14451 {
14452
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(stunclk>0)
14453 stunclk=0;
14454 84876 constant_walk_8_old(rate,homing,spw_floater);
14455
14456
14457 84876 misc=dir;
14458
14459 // If any higher-numbered segments were killed, segcnt can be too high,
14460 // leading to a crash
14461
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(index+segcnt>=guys.Count())
14462 segcnt=guys.Count()-index-1;
14463
14464
2/2
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 453901 times.
538777 for(int32_t i=index+1; i<index+segcnt+1; i++)
14465 {
14466 453901 enemy* segment=((enemy*)guys.spr(i));
14467
14468 // More validation - if segcnt was wrong, this may not
14469 // actually be a Moldorm segment
14470
1/2
✓ Branch 0 taken 453901 times.
✗ Branch 1 not taken.
453901 if(segment->id!=segid)
14471 {
14472 segcnt=i-index-1;
14473 break;
14474 }
14475
14476
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1)
14477 {
14478 84966 x=segment->x;
14479 84966 y=segment->y;
14480 84966 }
14481
14482 453901 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14483 //Script your own blasted segmented bosses!! -Z
14484 453901 segment->parent_script_UID = this->script_UID;
14485
4/4
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 369025 times.
✓ Branch 2 taken 12139 times.
✓ Branch 3 taken 72737 times.
453901 if((i==index+segcnt)&&(i!=index+1)) //tail
14486 {
14487 72737 segment->dummy_int[1]=2;
14488 72737 }
14489 else
14490 {
14491 381164 segment->dummy_int[1]=1;
14492 }
14493
14494
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1) //head
14495 {
14496 84966 segment->dummy_int[1]=0;
14497 84966 }
14498
14499
2/2
✓ Branch 0 taken 453501 times.
✓ Branch 1 taken 400 times.
453901 if(segment->hp <= 0)
14500 {
14501 400 int32_t offset=1;
14502
14503
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 618 times.
1018 for(int32_t j=i; j<index+segcnt; j++)
14504 {
14505 // Triple-check
14506
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if(((enemy*)guys.spr(j+1))->id!=segid)
14507 {
14508 segcnt=j-index+1; // Add 1 because of --segcnt below
14509 break;
14510 }
14511 618 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14512 618 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14513 618 }
14514
14515 400 segment->hclk=33;
14516 400 --segcnt;
14517 400 --i; // Recheck the same index in case multiple segments died at once
14518 400 }
14519 453901 }
14520
14521
2/2
✓ Branch 0 taken 84810 times.
✓ Branch 1 taken 66 times.
84876 if(segcnt==0)
14522 {
14523 66 clk2=19;
14524
14525 66 x=guys.spr(index+1)->x;
14526 66 y=guys.spr(index+1)->y;
14527 66 }
14528 }
14529
14530 86064 return false;
14531 86130 }
14532
14533 530 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14534 530 {
14535
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if( !(editorflags & ENEMY_FLAG5) )
14536 {
14537
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 x=128;
14538
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 y=48;
14539 530 }
14540
14541
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 530 times.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
530 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14542 530 hyofs=4;
14543 530 hit_width=hit_height=8;
14544 530 hxofs=1000;
14545 530 mainguy=count_enemy=false;
14546 530 parentclk = 0;
14547 530 bgsfx=-1;
14548 530 flags&=~guy_neverret;
14549 //deadsfx = WAV_EDEAD;
14550 530 isCore = false;
14551 530 }
14552
14553 460921 bool esMoldorm::animate(int32_t index)
14554 {
14555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(switch_hooked) return enemy::animate(index);
14556 // Shouldn't be possible, but better to be sure
14557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(index==0)
14558 dying=true;
14559
14560
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 453901 times.
460921 if(dying)
14561 {
14562
1/2
✓ Branch 0 taken 7020 times.
✗ Branch 1 not taken.
7020 if(!dmisc2)
14563 7020 item_set=0;
14564
14565 7020 return Dead(index);
14566 }
14567
14568
2/2
✓ Branch 0 taken 22038 times.
✓ Branch 1 taken 431863 times.
453901 if(clk>=0)
14569 {
14570 431863 hxofs=4;
14571 431863 step=((enemy*)guys.spr(index-1))->step;
14572
14573
2/2
✓ Branch 0 taken 32657 times.
✓ Branch 1 taken 399206 times.
431863 if(parentclk == 0)
14574 {
14575 32657 misc=dir;
14576 32657 dir=((enemy*)guys.spr(index-1))->misc;
14577 //do alignment, as in parent's animation :-/ -DD
14578 32657 x.doFloor();
14579 32657 y.doFloor();
14580 32657 }
14581
14582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(step)
14583 431863 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14584
14585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(!watch)
14586 {
14587 431863 sprite::move(step);
14588 431863 }
14589 431863 }
14590
14591 453901 return enemy::animate(index);
14592 460921 }
14593
14594 1735 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14595 {
14596
2/2
✓ Branch 0 taken 1588 times.
✓ Branch 1 taken 147 times.
1735 if(enemy::takehit(w,realweap))
14597 1588 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14598
14599 147 return 0;
14600 1735 }
14601
14602 462871 void esMoldorm::draw(BITMAP *dest)
14603 {
14604 462871 tile=o_tile;
14605 462871 int32_t fdiv = frate/4;
14606
1/2
✓ Branch 0 taken 462871 times.
✗ Branch 1 not taken.
462871 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14607
14608
2/2
✓ Branch 0 taken 385733 times.
✓ Branch 1 taken 77138 times.
462871 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14609 462871 efrate:((clk>=(frate>>1))?1:0);
14610
14611
2/2
✓ Branch 0 taken 77138 times.
✓ Branch 1 taken 385733 times.
462871 if(get_qr(qr_NEWENEMYTILES))
14612 {
14613 385733 tile+=dummy_int[1]*40;
14614
14615
2/2
✓ Branch 0 taken 17795 times.
✓ Branch 1 taken 367938 times.
385733 if(dir<8)
14616 {
14617 17795 flip=0;
14618
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14619
14620
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 if(dir>3) // Skip to the next row for diagonals
14621 tile+=4;
14622 17795 }
14623 else
14624 {
14625
8/9
✓ Branch 0 taken 40703 times.
✓ Branch 1 taken 50522 times.
✓ Branch 2 taken 41128 times.
✓ Branch 3 taken 50152 times.
✓ Branch 4 taken 42370 times.
✓ Branch 5 taken 40742 times.
✓ Branch 6 taken 49191 times.
✓ Branch 7 taken 53130 times.
✗ Branch 8 not taken.
367938 switch(dir-8) //directions get screwed up after 8. *shrug*
14626 {
14627 case up: //u
14628 40703 flip=0;
14629 40703 break;
14630
14631 case l_up: //d
14632 50522 flip=0;
14633 50522 tile+=4;
14634 50522 break;
14635
14636 case l_down: //l
14637 41128 flip=0;
14638 41128 tile+=8;
14639 41128 break;
14640
14641 case left: //r
14642 50152 flip=0;
14643 50152 tile+=12;
14644 50152 break;
14645
14646 case r_down: //ul
14647 42370 flip=0;
14648 42370 tile+=20;
14649 42370 break;
14650
14651 case down: //ur
14652 40742 flip=0;
14653 40742 tile+=24;
14654 40742 break;
14655
14656 case r_up: //dl
14657 49191 flip=0;
14658 49191 tile+=28;
14659 49191 break;
14660
14661 case right: //dr
14662 53130 flip=0;
14663 53130 tile+=32;
14664 53130 break;
14665 }
14666 }
14667
14668 385733 tile+=f2;
14669 385733 }
14670
14671
2/2
✓ Branch 0 taken 22092 times.
✓ Branch 1 taken 440779 times.
462871 if(clk>=0)
14672 440779 enemy::draw(dest);
14673 462871 }
14674
14675 239 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14676 239 {
14677
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if( !(editorflags & ENEMY_FLAG5) )
14678 {
14679
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 x=64;
14680
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 y=80;
14681 239 }
14682 //else { x = X; y = Y; }
14683 //zprint2("lanmola index is %d\n", index);
14684 //byte legaldirs = 0;
14685 239 int32_t incr = 16;
14686 //int32_t possiiblepos = 0;
14687 //int32_t positions[8] = {0};
14688
14689 //Don't spawn in pits.
14690
5/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149 times.
✓ Branch 7 taken 90 times.
239 if ( m_walkflag_simple(x, y) )
14691 {
14692 //zprint2("Can't spawn here.\n");
14693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 for ( ; incr < 240; incr += 16 )
14694 {
14695 //move if we spawn over a pit
14696 //check each direction
14697
7/12
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 124 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 124 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 120 times.
124 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14698 {
14699 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14700
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14701 }
14702
7/12
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28 times.
✓ Branch 11 taken 92 times.
120 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14703 {
14704 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14705
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 x+=incr; break;
14706 }
14707
9/16
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 92 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 60 times.
92 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14708 {
14709 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14710
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14711 }
14712
8/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
60 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14713 {
14714 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14715 x+=incr; y-=incr; break;
14716 }
14717
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14718 {
14719 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14720 y -= incr; break;
14721 }
14722
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14723 {
14724 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14725 y+=incr; break;
14726 }
14727
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14728 {
14729 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14730
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14731 }
14732
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14733 {
14734 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14735 x+=incr; y+=incr; break;
14736 }
14737 34 else continue;
14738
14739 }
14740
14741 90 }
14742
14743 239 dir=up;
14744 239 superman=1;
14745 239 fading=fade_invisible;
14746 239 hxofs=1000;
14747 239 segcnt=clk;
14748 239 clk=0;
14749 //set up move history
14750
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1691 times.
1930 for(int32_t i=0; i <= (1<<dmisc2); i++)
14751
3/6
✓ Branch 0 taken 1691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1691 times.
✗ Branch 5 not taken.
1691 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14752 239 }
14753
14754 134485 bool eLanmola::animate(int32_t index)
14755 {
14756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134485 times.
134485 if(switch_hooked) return enemy::animate(index);
14757
2/2
✓ Branch 0 taken 112061 times.
✓ Branch 1 taken 22424 times.
134485 if(clk==0)
14758 {
14759 22424 removearmos(x,y,ffcactivated);
14760 22424 }
14761
14762
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 132623 times.
134485 if(clk2)
14763 {
14764
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 98 times.
1862 if(--clk2 == 0)
14765 {
14766
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 20 times.
98 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14767 78 leave_item();
14768
14769 98 stop_bgsfx(index);
14770 98 return true;
14771 }
14772
14773 1764 return false;
14774 }
14775
14776
14777 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14778 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14779 //I've added a complete movement history to this enemy to compensate -DD
14780 132623 constant_walk(rate,homing,spw_none);
14781 132623 prevState.pop_front();
14782 132623 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14783
14784 // This could cause a crash with Moldorms. I didn't see the same problem
14785 // with Lanmolas, but it looks like it ought to be possible, so here's
14786 // the same solution. - Saf
14787
1/2
✓ Branch 0 taken 132623 times.
✗ Branch 1 not taken.
132623 if(index+segcnt>=guys.Count())
14788 segcnt=guys.Count()-index-1;
14789
14790
2/2
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 599039 times.
731662 for(int32_t i=index+1; i<index+segcnt+1; i++)
14791 {
14792 599039 enemy* segment=((enemy*)guys.spr(i));
14793
14794 // More validation in case segcnt is wrong
14795
1/2
✓ Branch 0 taken 599039 times.
✗ Branch 1 not taken.
599039 if((segment->id&0xFFF)!=(id&0xFFF))
14796 {
14797 segcnt=i-index-1;
14798 break;
14799 }
14800
14801 599039 segment->o_tile=o_tile;
14802 599039 segment->parent_script_UID = this->script_UID;
14803
4/4
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 466416 times.
✓ Branch 2 taken 19514 times.
✓ Branch 3 taken 113109 times.
599039 if((i==index+segcnt)&&(i!=index+1))
14804 {
14805 113109 segment->dummy_int[1]=1; //tail
14806 113109 }
14807 else
14808 {
14809 485930 segment->dummy_int[1]=0;
14810 }
14811
14812
2/2
✓ Branch 0 taken 598467 times.
✓ Branch 1 taken 572 times.
599039 if(segment->hp <= 0)
14813 {
14814
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 977 times.
1549 for(int32_t j=i; j<index+segcnt; j++)
14815 {
14816 // Triple-check
14817
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14818 {
14819 segcnt=j-index+1; // Add 1 because of --segcnt below
14820 break;
14821 }
14822 977 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14823 977 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14824 977 }
14825
14826 572 ((enemy*)guys.spr(i))->hclk=33;
14827 572 --segcnt;
14828 572 --i; // Recheck the same index in case multiple segments died at once
14829 572 }
14830 599039 }
14831
14832
2/2
✓ Branch 0 taken 132525 times.
✓ Branch 1 taken 98 times.
132623 if(segcnt==0)
14833 {
14834 98 clk2=19;
14835 98 x=guys.spr(index+1)->x;
14836 98 y=guys.spr(index+1)->y;
14837 98 setmapflag(mTMPNORET);
14838 98 }
14839
14840 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14841 //which is... disastrous.
14842 132623 hp = 1;
14843 132623 return enemy::animate(index);
14844 134485 }
14845
14846 1250 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14847 1250 {
14848
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 if( !(editorflags & ENEMY_FLAG5) )
14849 {
14850
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 x=64;
14851
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 y=80;
14852 1250 }
14853 1250 int32_t incr = 16;
14854 //Don't spawn in pits.
14855
5/8
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 450 times.
1250 if ( m_walkflag_simple(x, y) )
14856 {
14857 //zprint2("Can't spawn here.\n");
14858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
620 for ( ; incr < 240; incr += 16 )
14859 {
14860 //move if we spawn over a pit
14861 //check each direction
14862
7/12
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 620 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 620 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 620 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 600 times.
620 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14863 {
14864 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14865
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14866 }
14867
7/12
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 600 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 600 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 140 times.
✓ Branch 11 taken 460 times.
600 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14868 {
14869 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14870
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 x+=incr; break;
14871 }
14872
9/16
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 460 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 460 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 460 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 460 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 300 times.
460 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14873 {
14874 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14875
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14876 }
14877
8/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 300 times.
300 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14878 {
14879 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14880 x+=incr; y-=incr; break;
14881 }
14882
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14883 {
14884 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14885 y -= incr; break;
14886 }
14887
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14888 {
14889 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14890 y+=incr; break;
14891 }
14892
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14893 {
14894 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14895
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14896 }
14897
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14898 {
14899 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14900 x+=incr; y+=incr; break;
14901 }
14902 170 else continue;
14903
14904 }
14905
14906 450 }
14907
14908 1250 hxofs=1000;
14909 1250 hit_width=8;
14910 1250 mainguy=false;
14911 1250 count_enemy=(id<0x2000)?true:false;
14912
14913 //set up move history
14914
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 8910 times.
10160 for(int32_t i=0; i <= (1<<dmisc2); i++)
14915
3/6
✓ Branch 0 taken 8910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8910 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8910 times.
✗ Branch 5 not taken.
8910 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14916
14917 1250 bgsfx = -1;
14918 1250 isCore = false;
14919 1250 flags&=~guy_neverret;
14920 1250 }
14921
14922 609335 bool esLanmola::animate(int32_t index)
14923 {
14924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609335 times.
609335 if(switch_hooked) return enemy::animate(index);
14925 // Shouldn't be possible, but who knows
14926
1/2
✓ Branch 0 taken 609335 times.
✗ Branch 1 not taken.
609335 if(index==0)
14927 dying=true;
14928
14929
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 599039 times.
609335 if(dying)
14930 {
14931 10296 xofs=0;
14932
14933
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 8496 times.
10296 if(!dmisc3)
14934 8496 item_set=0;
14935
14936 10296 return Dead(index);
14937 }
14938
14939
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 579729 times.
599039 if(clk>=0)
14940 {
14941 579729 hxofs=4;
14942
14943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579729 times.
579729 if(!watch)
14944 {
14945 579729 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14946 579729 prevState.pop_front();
14947 579729 prevState.push_back(newstate);
14948 579729 x = newstate.first.first;
14949 579729 y = newstate.first.second;
14950 579729 dir = newstate.second;
14951 579729 }
14952 579729 }
14953
14954 599039 return enemy::animate(index);
14955 609335 }
14956
14957 1513 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14958 {
14959
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 131 times.
1513 if(enemy::takehit(w,realweap))
14960 1382 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14961
14962 131 return 0;
14963 1513 }
14964
14965 610611 void esLanmola::draw(BITMAP *dest)
14966 {
14967 610611 tile=o_tile;
14968 610611 int32_t fdiv = frate/4;
14969
1/2
✓ Branch 0 taken 610611 times.
✗ Branch 1 not taken.
610611 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14970
14971
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14972 610611 efrate:((clk>=(frate>>1))?1:0);
14973
14974
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 if(get_qr(qr_NEWENEMYTILES))
14975 {
14976
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
14977 {
14978 269264 tile+=20;
14979
14980
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
14981 {
14982 59482 tile+=20;
14983 59482 }
14984 269264 }
14985
14986
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
14987 {
14988 case up:
14989 70158 flip=0;
14990 70158 break;
14991
14992 case down:
14993 71956 flip=0;
14994 71956 tile+=4;
14995 71956 break;
14996
14997 case left:
14998 93557 flip=0;
14999 93557 tile+=8;
15000 93557 break;
15001
15002 case right:
15003 101862 flip=0;
15004 101862 tile+=12;
15005 101862 break;
15006 }
15007
15008 337533 tile+=f2;
15009 337533 }
15010 else
15011 {
15012
2/2
✓ Branch 0 taken 66631 times.
✓ Branch 1 taken 206447 times.
273078 if(id>=0x2000)
15013 {
15014 206447 tile+=1;
15015 206447 }
15016 }
15017
15018
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 591301 times.
610611 if(clk>=0)
15019 591301 enemy::draw(dest);
15020 610611 }
15021
15022 59 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
15023 59 {
15024 //these are here to bypass compiler warnings about unused arguments
15025 59 Clk=Clk;
15026 59 superman=1;
15027
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 dir=(zc_oldrand()&7)+8;
15028 59 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
15029
15030
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 59 times.
327 for(int32_t i=0; i<armcnt; i++)
15031 268 arm[i]=i;
15032
15033 59 fading=fade_blue_poof;
15034 //nets+4680;
15035 59 adjusted=false;
15036 59 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
15037
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15038 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15039 // al_trace("Enemy txsz:%i\n", txsz);
15040
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15041
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15042
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15043
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15044
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15045
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15046 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15047
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15048
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15049 {
15050 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15051 }
15052
15053
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15054 59 }
15055
15056 30979 bool eManhandla::animate(int32_t index)
15057 {
15058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30979 times.
30979 if(switch_hooked) return enemy::animate(index);
15059
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 30209 times.
30979 if(dying)
15060 770 return Dead(index);
15061
15062
2/2
✓ Branch 0 taken 28958 times.
✓ Branch 1 taken 1251 times.
30209 if(clk==0)
15063 {
15064 1251 removearmos(x,y,ffcactivated);
15065 1251 }
15066
15067
15068 // check arm status, move dead ones to end of group
15069
2/2
✓ Branch 0 taken 94683 times.
✓ Branch 1 taken 30209 times.
124892 for(int32_t i=0; i<armcnt; i++)
15070 {
15071 94683 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
15072
3/4
✓ Branch 0 taken 94683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 94479 times.
94683 if(!cur_arm || cur_arm->dying)
15073 {
15074
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 204 times.
456 for(int32_t j=i; j<armcnt-1; j++)
15075 {
15076 252 zc_swap(arm[j],arm[j+1]);
15077 252 guys.swap(index+j+1,index+j+2);
15078 252 }
15079
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 36 times.
204 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
15080 {
15081 36 leave_item();
15082 36 }
15083 204 --armcnt;
15084 204 --i;
15085 204 continue;
15086 }
15087
2/2
✓ Branch 0 taken 94211 times.
✓ Branch 1 taken 268 times.
94479 if(!adjusted)
15088 {
15089
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 64 times.
268 if(!dmisc2)
15090 {
15091 204 cur_arm->o_tile=o_tile+40;
15092 204 cur_arm->parent_script_UID = this->script_UID;
15093 204 }
15094 else
15095 {
15096 64 cur_arm->o_tile=o_tile+160;
15097 64 cur_arm->parent_script_UID = this->script_UID;
15098 }
15099 268 }
15100 94479 }
15101
15102 30209 adjusted=true;
15103
15104 // move or die
15105
2/2
✓ Branch 0 taken 30166 times.
✓ Branch 1 taken 43 times.
30209 if(armcnt==0)
15106 43 hp=0;
15107 else
15108 {
15109 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
15110
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
15111
1/2
✓ Branch 0 taken 30166 times.
✗ Branch 1 not taken.
30166 if (step > 4.5_zf) step = 4.5_zf;
15112 30166 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
15113
15114
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 if(!dmisc2)
15115 {
15116
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 27285 times.
107777 for(int32_t i=0; i<armcnt; i++)
15117 {
15118
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15119 {
15120 case 0:
15121 18990 dy1=-24;
15122 18990 break;
15123
15124 case 1:
15125 21427 dy2=31;
15126 21427 break;
15127
15128 case 2:
15129 19973 dx1=-16;
15130 19973 break;
15131
15132 case 3:
15133 20102 dx2=31;
15134 20102 break;
15135 }
15136 80492 }
15137 27285 }
15138 else
15139 {
15140 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
15141
15142
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
15143 {
15144
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
15145 {
15146 case 0:
15147 4279 dy1=-32;
15148 4279 break;
15149
15150 case 1:
15151 3184 dy2=39;
15152 3184 break;
15153
15154 case 2:
15155 2549 dx1=-24;
15156 2549 break;
15157
15158 case 3:
15159 3975 dx2=39;
15160 3975 break;
15161 }
15162 13987 }
15163 }
15164
15165 30166 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
15166
15167
2/2
✓ Branch 0 taken 94479 times.
✓ Branch 1 taken 30166 times.
124645 for(int32_t i=0; i<armcnt; i++)
15168 {
15169 94479 zfix dx=(zfix)0,dy=(zfix)0;
15170
15171
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 13987 times.
94479 if(!dmisc2)
15172 {
15173
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15174 {
15175 case 0:
15176 18990 dy=-16;
15177 18990 break;
15178
15179 case 1:
15180 21427 dy=16;
15181 21427 break;
15182
15183 case 2:
15184 19973 dx=-16;
15185 19973 break;
15186
15187 case 3:
15188 20102 dx=16;
15189 20102 break;
15190 }
15191 80492 }
15192 else
15193 {
15194
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
15195 {
15196 case 0:
15197 1680 dy=-24;
15198 1680 dx=-8;
15199 1680 break;
15200
15201 case 1:
15202 1789 dy=24;
15203 1789 dx=8;
15204 1789 break;
15205
15206 case 2:
15207 1292 dx=-24;
15208 1292 dy=8;
15209 1292 break;
15210
15211 case 3:
15212 2015 dx=24;
15213 2015 dy=-8;
15214 2015 break;
15215
15216 case 4:
15217 2599 dy=-24;
15218 2599 dx=8;
15219 2599 break;
15220
15221 case 5:
15222 1395 dy=24;
15223 1395 dx=-8;
15224 1395 break;
15225
15226 case 6:
15227 1257 dx=-24;
15228 1257 dy=-8;
15229 1257 break;
15230
15231 case 7:
15232 1960 dx=24;
15233 1960 dy=8;
15234 1960 break;
15235 }
15236 }
15237
15238 94479 guys.spr(index+i+1)->x = x+dx;
15239 94479 guys.spr(index+i+1)->y = y+dy;
15240 94479 }
15241 }
15242
15243 30209 return enemy::animate(index);
15244 30979 }
15245
15246
15247 1338 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
15248 {
15249 1338 int32_t wpnId = w->id;
15250
15251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1338 times.
1338 if(dying)
15252 return 0;
15253
15254
3/4
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1338 switch(wpnId)
15255 {
15256 case wBomb:
15257 case wSBomb:
15258 case wSword:
15259 case wHammer:
15260 case wWand:
15261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 448 times.
448 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15262
15263 case wLitBomb:
15264 case wLitSBomb:
15265 case wBait:
15266 case wWhistle:
15267 case wFire:
15268 case wWind:
15269 case wSSparkle:
15270 case wFSparkle:
15271 case wPhantom:
15272 1321 return 0;
15273
15274 case wHookshot:
15275 case wBrang:
15276 sfx(WAV_CHINK,pan(int32_t(x)));
15277 break;
15278
15279 default:
15280
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15281 else sfx(WAV_CHINK,pan(int32_t(x)));
15282
15283 17 }
15284
15285 17 return 1;
15286 1338 }
15287
15288 30977 void eManhandla::draw(BITMAP *dest)
15289 {
15290 30977 tile=o_tile;
15291 30977 int32_t fdiv = frate/4;
15292
1/2
✓ Branch 0 taken 30977 times.
✗ Branch 1 not taken.
30977 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15293
15294
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15295 30977 efrate:((clk>=(frate>>1))?1:0);
15296
15297
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 if(get_qr(qr_NEWENEMYTILES))
15298 {
15299
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 19500 times.
22018 if(!dmisc2)
15300 {
15301
8/9
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 2274 times.
✓ Branch 2 taken 2799 times.
✓ Branch 3 taken 2974 times.
✓ Branch 4 taken 1879 times.
✓ Branch 5 taken 1895 times.
✓ Branch 6 taken 2025 times.
✓ Branch 7 taken 3189 times.
✗ Branch 8 not taken.
19500 switch(dir-8) //directions get screwed up after 8. *shrug*
15302 {
15303 case up: //u
15304 2465 flip=0;
15305 2465 break;
15306
15307 case l_up: //d
15308 2274 flip=0;
15309 2274 tile+=4;
15310 2274 break;
15311
15312 case l_down: //l
15313 2799 flip=0;
15314 2799 tile+=8;
15315 2799 break;
15316
15317 case left: //r
15318 2974 flip=0;
15319 2974 tile+=12;
15320 2974 break;
15321
15322 case r_down: //ul
15323 1879 flip=0;
15324 1879 tile+=20;
15325 1879 break;
15326
15327 case down: //ur
15328 1895 flip=0;
15329 1895 tile+=24;
15330 1895 break;
15331
15332 case r_up: //dl
15333 2025 flip=0;
15334 2025 tile+=28;
15335 2025 break;
15336
15337 case right: //dr
15338 3189 flip=0;
15339 3189 tile+=32;
15340 3189 break;
15341 }
15342
15343 19500 tile+=f2;
15344 19500 enemy::draw(dest);
15345 19500 } //manhandla 2, big body
15346 else
15347 {
15348
15349
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
15350 {
15351 case up: //u
15352 357 flip=0;
15353 357 break;
15354
15355 case l_up: //d
15356 483 flip=0;
15357 483 tile+=8;
15358 483 break;
15359
15360 case l_down: //l
15361 500 flip=0;
15362 500 tile+=40;
15363 500 break;
15364
15365 case left: //r
15366 315 flip=0;
15367 315 tile+=48;
15368 315 break;
15369
15370 case r_down: //ul
15371 196 flip=0;
15372 196 tile+=80;
15373 196 break;
15374
15375 case down: //ur
15376 215 flip=0;
15377 215 tile+=88;
15378 215 break;
15379
15380 case r_up: //dl
15381 164 flip=0;
15382 164 tile+=120;
15383 164 break;
15384
15385 case right: //dr
15386 288 flip=0;
15387 288 tile+=128;
15388 288 break;
15389 }
15390
15391 2518 tile+=(f2*2);
15392 2518 xofs-=8;
15393 2518 yofs-=8;
15394 2518 drawblock(dest,15);
15395 2518 xofs+=8;
15396 2518 yofs+=8;
15397 }
15398 22018 }
15399 else
15400 {
15401
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 8444 times.
8959 if(!dmisc2)
15402 {
15403 8444 enemy::draw(dest);
15404 8444 }
15405 else
15406 {
15407 515 xofs-=8;
15408 515 yofs-=8;
15409 515 enemy::draw(dest);
15410 515 xofs+=16;
15411 515 enemy::draw(dest);
15412 515 yofs+=16;
15413 515 enemy::draw(dest);
15414 515 xofs-=16;
15415 515 enemy::draw(dest);
15416 515 xofs+=8;
15417 515 yofs-=8;
15418 }
15419 }
15420 30977 }
15421
15422 268 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15423 268 {
15424 268 id=misc=clk;
15425 268 dir = clk & 3;
15426 268 clk=0;
15427 268 mainguy=count_enemy=false;
15428 268 dummy_bool[0]=false;
15429 268 item_set=0;
15430 268 bgsfx=-1;
15431 268 deadsfx = WAV_EDEAD;
15432 268 flags &= (~guy_neverret);
15433 268 isCore = false;
15434 //Probably will be buggy. -Z 12 AUG 2020
15435 268 SIZEflags = d->SIZEflags;
15436
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15437 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15438 // al_trace("Enemy txsz:%i\n", txsz);
15439
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15440
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15442
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15443
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15444
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15445 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15446
1/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15447
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15448 {
15449 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15450 }
15451
15452
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15453 268 }
15454
15455 98135 bool esManhandla::animate(int32_t index)
15456 {
15457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98135 times.
98135 if(switch_hooked) return enemy::animate(index);
15458
2/2
✓ Branch 0 taken 3656 times.
✓ Branch 1 taken 94479 times.
98135 if(dying)
15459 3656 return Dead(index);
15460
15461
2/2
✓ Branch 0 taken 6029 times.
✓ Branch 1 taken 88450 times.
94479 if(clk==0)
15462 {
15463 6029 removearmos(x,y,ffcactivated);
15464 6029 }
15465
15466
2/2
✓ Branch 0 taken 80858 times.
✓ Branch 1 taken 13621 times.
94479 if(--clk2<=0)
15467 {
15468 13621 clk2=unsigned(zc_oldrand())%5+5;
15469 13621 clk3^=1;
15470 13621 }
15471
15472
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 93728 times.
94479 if(!(zc_oldrand()&127))
15473 {
15474 751 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15475 751 sfx(wpnsfx(wpn),pan(int32_t(x)));
15476 751 }
15477
15478 94479 return enemy::animate(index);
15479 98135 }
15480
15481 98127 void esManhandla::draw(BITMAP *dest)
15482 {
15483 98127 tile=o_tile;
15484 98127 int32_t fdiv = frate/4;
15485
1/2
✓ Branch 0 taken 98127 times.
✗ Branch 1 not taken.
98127 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15486
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15487 98127 efrate:((clk>=(frate>>1))?1:0);
15488
15489
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 if(get_qr(qr_NEWENEMYTILES))
15490 {
15491
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17260 times.
✓ Branch 2 taken 19375 times.
✓ Branch 3 taken 18024 times.
✓ Branch 4 taken 18287 times.
72946 switch(misc&3)
15492 {
15493 case up:
15494 17260 break;
15495
15496 case down:
15497 19375 tile+=4;
15498 19375 break;
15499
15500 case left:
15501 18024 tile+=8;
15502 18024 break;
15503
15504 case right:
15505 18287 tile+=12;
15506 18287 break;
15507 }
15508
15509 72946 tile+=f2;
15510 72946 }
15511 else
15512 {
15513
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6921 times.
✓ Branch 2 taken 5410 times.
✓ Branch 3 taken 6148 times.
✓ Branch 4 taken 6702 times.
25181 switch(misc&3)
15514 {
15515 case down:
15516 6148 flip=2;
15517
15518 [[fallthrough]];
15519 case up:
15520 13069 tile=(clk3)?188:189;
15521 13069 break;
15522
15523 case right:
15524 6702 flip=1;
15525 [[fallthrough]];
15526
15527 case left:
15528 12112 tile=(clk3)?186:187;
15529 12112 break;
15530 }
15531 }
15532
15533 98127 enemy::draw(dest);
15534 98127 }
15535
15536 94 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15537 94 {
15538
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( !(editorflags & ENEMY_FLAG5) )
15539 {
15540
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x = 120;
15541
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y = 48;
15542 94 }
15543 else
15544 {
15545 if ( !(editorflags & ENEMY_FLAG6) )
15546 {
15547 x = X; y = Y;
15548 }
15549 else
15550 {
15551 x = X+8; y = Y;
15552 }
15553 }
15554 94 hzsz = 32; // can't be jumped.
15555 94 flameclk=0;
15556 94 misc=clk; // total head count
15557 94 clk3=clk; // live head count
15558 94 clk=0;
15559 94 clk2=60; // fire ball clock
15560 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15561
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15562 94 dir = down;
15563 94 hxofs=4;
15564 94 hit_width=8;
15565 // frate=17*4;
15566 94 fading=fade_blue_poof;
15567 //nets+5420;
15568
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 23 times.
94 if(get_qr(qr_NEWENEMYTILES))
15569 {
15570 /*
15571 necktile=o_tile+8;
15572 if (dmisc3)
15573 {
15574 necktile+=8;
15575 }
15576 */
15577 71 necktile=o_tile+dmisc6;
15578 71 }
15579 else
15580 {
15581 23 necktile=s_tile;
15582 }
15583 94 }
15584
15585 70509 bool eGleeok::animate(int32_t index)
15586 {
15587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70509 times.
70509 if(switch_hooked) return enemy::animate(index);
15588
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69261 times.
70509 if(dying)
15589 1248 return Dead(index);
15590
15591
2/2
✓ Branch 0 taken 68945 times.
✓ Branch 1 taken 316 times.
69261 if(clk==0)
15592 {
15593 316 removearmos(x,y,ffcactivated);
15594 316 }
15595
15596 // Check if a head was killed somehow...
15597
2/2
✓ Branch 0 taken 35220 times.
✓ Branch 1 taken 34041 times.
69261 if(index+1+clk3>=guys.Count())
15598 34041 clk3=guys.Count()-index-1;
15599
2/2
✓ Branch 0 taken 13804 times.
✓ Branch 1 taken 55457 times.
69261 if(index+1+misc>=guys.Count())
15600 55457 misc=guys.Count()-index-1;
15601
15602 //fix for the "kill all enemies" item
15603
2/2
✓ Branch 0 taken 69255 times.
✓ Branch 1 taken 6 times.
69261 if(hp==-1000)
15604 {
15605
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15606 {
15607 // I haven't seen this fail, but it seems like it ought to be
15608 // possible, so I'm checking for it. - Saf
15609
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15610 break;
15611 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15612 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15613 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15614 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15615 12 }
15616
15617 6 clk3=0;
15618
15619
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15620 {
15621
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15622 break;
15623 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15624 12 }
15625 6 }
15626
15627
2/2
✓ Branch 0 taken 157172 times.
✓ Branch 1 taken 69261 times.
226433 for(int32_t i=0; i<clk3; i++)
15628 {
15629 157172 enemy *head = ((enemy*)guys.spr(index+i+1));
15630 157172 head->dummy_int[1]=necktile;
15631 157172 head->parent_script_UID = this->script_UID;
15632
15633
2/2
✓ Branch 0 taken 103123 times.
✓ Branch 1 taken 54049 times.
157172 if(get_qr(qr_NEWENEMYTILES))
15634 {
15635 103123 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15636 103123 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15637 103123 }
15638 else
15639 {
15640 54049 head->dummy_int[2]=necktile+1; //connected head tile
15641 54049 head->dummy_int[3]=necktile+2; //flying head tile
15642 }
15643
15644 157172 head->dmisc5=dmisc5; //neck segments
15645
15646 /*
15647 if (dmisc3)
15648 {
15649 head->dummy_bool[0]=true;
15650 }
15651 */
15652
2/2
✓ Branch 0 taken 154379 times.
✓ Branch 1 taken 2793 times.
157172 if(head->hclk)
15653 {
15654
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 569 times.
2793 if(hclk==0)
15655 {
15656 569 hp -= 1000 - head->hp;
15657 569 hclk = 33;
15658
15659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 569 times.
569 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15660
15661 569 sfx(WAV_EHIT,pan(int32_t(head->x)));
15662 569 }
15663
15664 2793 head->hclk = 0;
15665 2793 }
15666
15667 // Must be set in case of naughty ZScripts
15668 157172 head->hp = 1000;
15669 157172 }
15670
15671
2/2
✓ Branch 0 taken 69069 times.
✓ Branch 1 taken 192 times.
69261 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
15672 {
15673 192 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15674 192 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
15675 192 }
15676
15677
2/2
✓ Branch 0 taken 19312 times.
✓ Branch 1 taken 49949 times.
69261 if(!dmisc3)
15678 {
15679
4/4
✓ Branch 0 taken 2801 times.
✓ Branch 1 taken 47148 times.
✓ Branch 2 taken 674 times.
✓ Branch 3 taken 2127 times.
49949 if(++clk2>72 && !(zc_oldrand()&3))
15680 {
15681 674 int32_t i=zc_oldrand()%misc;
15682 674 enemy *head = ((enemy*)guys.spr(index+i+1));
15683 674 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15684 674 sfx(wpnsfx(wpn),pan(int32_t(x)));
15685 674 clk2=0;
15686 674 }
15687 49949 }
15688 else
15689 {
15690
4/4
✓ Branch 0 taken 827 times.
✓ Branch 1 taken 18485 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 189 times.
19312 if(++clk2>100 && !(zc_oldrand()&3))
15691 {
15692 189 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15693 189 head->timer=zc_oldrand()%50+50;
15694 189 clk2=0;
15695 189 }
15696 }
15697
15698
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 69191 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
69261 if((hp<=0 && !immortal))
15699 {
15700
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 70 times.
256 for(int32_t i=0; i<misc; i++)
15701 186 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15702
15703
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 67 times.
70 if(flags&guy_neverret) never_return(index);
15704 70 }
15705
15706 69261 return enemy::animate(index);
15707 70509 }
15708
15709 155 int32_t eGleeok::takehit(weapon*,weapon*)
15710 {
15711 155 return 0;
15712 }
15713
15714 70829 void eGleeok::draw(BITMAP *dest)
15715 {
15716 70829 tile=o_tile;
15717
15718
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69581 times.
70829 if(dying)
15719 {
15720 1248 enemy::draw(dest);
15721 1248 return;
15722 }
15723
15724 69581 int32_t f=clk/17;
15725
15726
2/2
✓ Branch 0 taken 46906 times.
✓ Branch 1 taken 22675 times.
69581 if(get_qr(qr_NEWENEMYTILES))
15727 {
15728 // body
15729 46906 xofs=-8;
15730 46906 yofs=32;
15731
15732
4/4
✓ Branch 0 taken 35926 times.
✓ Branch 1 taken 3851 times.
✓ Branch 2 taken 3602 times.
✓ Branch 3 taken 3527 times.
46906 switch(f)
15733
15734 {
15735 case 0:
15736 3851 tile+=0;
15737 3851 break;
15738
15739 case 1:
15740 3602 tile+=2;
15741 3602 break;
15742
15743 case 2:
15744 3527 tile+=4;
15745 3527 break;
15746
15747 default:
15748 35926 tile+=6;
15749 35926 break;
15750 }
15751 46906 }
15752 else
15753 {
15754 // body
15755 22675 xofs=-8;
15756 22675 yofs=32;
15757
15758
3/3
✓ Branch 0 taken 19415 times.
✓ Branch 1 taken 1645 times.
✓ Branch 2 taken 1615 times.
22675 switch(f)
15759 {
15760 case 0:
15761 1645 tile+=0;
15762 1645 break;
15763
15764 case 2:
15765 1615 tile+=4;
15766 1615 break;
15767
15768 default:
15769 19415 tile+=2;
15770 19415 break;
15771 }
15772 }
15773
15774 69581 enemy::drawblock(dest,15);
15775 70829 }
15776
15777 70829 void eGleeok::draw2(BITMAP *dest)
15778 {
15779 // the neck stub
15780 70829 tile=necktile;
15781 70829 xofs=0;
15782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70829 times.
70829 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15783
15784
2/2
✓ Branch 0 taken 23071 times.
✓ Branch 1 taken 47758 times.
70829 if(get_qr(qr_NEWENEMYTILES))
15785 {
15786 47758 tile+=((clk&24)>>3);
15787 47758 }
15788
15789
3/4
✓ Branch 0 taken 69581 times.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69581 times.
70829 if(hp > 0 && !dont_draw())
15790 {
15791
4/4
✓ Branch 0 taken 1374 times.
✓ Branch 1 taken 68207 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 637 times.
69581 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15792 737 sprite::drawcloaked(dest);
15793 else
15794 68844 sprite::draw(dest);
15795 69581 }
15796 70829 }
15797
15798
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
536 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15799 268 {
15800
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 xoffset=0;
15801
2/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
268 yoffset=(zfix)((dmisc5*4+2));
15802 // dummy_bool[0]=false;
15803 268 timer=0;
15804 /* fixing */
15805 268 hp=1000;
15806
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 step=1;
15807 268 item_set=0;
15808 //x=120; y=70;
15809
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 x = xoffset+parent->x;
15810
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 y = yoffset+parent->y;
15811 268 hxofs=4;
15812 268 hit_width=8;
15813
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
268 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15814 268 clk2=clk; // how int32_t to wait before moving first time
15815 268 clk=0;
15816 268 mainguy=count_enemy=false;
15817
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dir=zc_oldrand();
15818 268 clk3=((dir&2)>>1)+2; // left or right
15819 268 dir&=1; // up or down
15820
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dmisc5=vbound(dmisc5,1,255);
15821 268 isCore = false;
15822
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 parentCore = parent->getUID();
15823
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 268 times.
1340 for(int32_t i=0; i<dmisc5; i++)
15824 {
15825 1072 nxoffset[i] = 0;
15826 1072 nyoffset[i] = 0;
15827
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15828
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15829 1072 }
15830
15831 268 necktile=0;
15832 //TODO compatibility? -DD
15833 /*
15834 for(int32_t i=0; i<4; i++)
15835 {
15836 nx[i]=124;
15837 ny[i]=i*6+48;
15838 }*/
15839 268 bgsfx=-1;
15840 //no need for deadsfx
15841 268 }
15842
15843 202199 bool esGleeok::animate(int32_t index)
15844 {
15845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202199 times.
202199 if(switch_hooked) return enemy::animate(index);
15846 // don't call removearmos() - it's a segment.
15847
15848 202199 dmisc5=vbound(dmisc5,1,255);
15849
15850
2/2
✓ Branch 0 taken 45213 times.
✓ Branch 1 taken 156986 times.
202199 if(misc == 0)
15851 {
15852 156986 x = (xoffset+parent->x);
15853 156986 y = (yoffset+parent->y);
15854
15855
2/2
✓ Branch 0 taken 627944 times.
✓ Branch 1 taken 156986 times.
784930 for(int32_t i=0; i<dmisc5; i++)
15856 {
15857 627944 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15858 627944 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15859 627944 }
15860 156986 }
15861
15862 // set up the head tiles
15863 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15864 /*
15865 if (dummy_bool[0]) //if this is a flame gleeok
15866 {
15867 headtile+=180;
15868 }
15869 */
15870 202199 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15871 202199 flyingheadtile=dummy_int[3];
15872
15873 // set up the neck tiles
15874 202199 necktile=dummy_int[1];
15875
15876
2/2
✓ Branch 0 taken 74462 times.
✓ Branch 1 taken 127737 times.
202199 if(get_qr(qr_NEWENEMYTILES))
15877 {
15878 127737 necktile+=((clk&24)>>3);
15879 127737 }
15880
15881 /*
15882 else
15883 {
15884 necktile=145;
15885 }
15886 */
15887 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15888
15889
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 156986 times.
✓ Branch 2 taken 44881 times.
✓ Branch 3 taken 134 times.
✓ Branch 4 taken 198 times.
202199 switch(misc)
15890 {
15891 case 0: // live head
15892 // set up the attached head tiles
15893 156986 tile=headtile;
15894
15895
2/2
✓ Branch 0 taken 53978 times.
✓ Branch 1 taken 103008 times.
156986 if(get_qr(qr_NEWENEMYTILES))
15896 {
15897 103008 tile+=((clk&24)>>3);
15898 /*
15899 if (dummy_bool[0]) {
15900 tile+=1561;
15901 }
15902 */
15903 103008 }
15904
15905 /*
15906 else
15907 {
15908 tile=146;
15909 }
15910 */
15911
4/4
✓ Branch 0 taken 40101 times.
✓ Branch 1 taken 116885 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 35617 times.
156986 if(++clk2>=0 && !(clk2&3))
15912 {
15913
2/2
✓ Branch 0 taken 34833 times.
✓ Branch 1 taken 784 times.
35617 if(y<= (int32_t)parent->y + 8) dir=down;
15914
15915
2/2
✓ Branch 0 taken 34879 times.
✓ Branch 1 taken 738 times.
35617 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15916
15917
4/4
✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 31889 times.
✓ Branch 2 taken 3626 times.
✓ Branch 3 taken 102 times.
35617 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15918 {
15919 102 dir^=1;
15920 102 }
15921
15922 35617 zfix tempx = x;
15923 35617 zfix tempy = y;
15924
15925 35617 sprite::move(step);
15926 35617 xoffset += (x-tempx);
15927 35617 yoffset += (y-tempy);
15928
15929
2/2
✓ Branch 0 taken 1490 times.
✓ Branch 1 taken 34127 times.
35617 if(clk2>=4)
15930 {
15931 1490 clk3^=1;
15932 1490 clk2=-4;
15933 1490 }
15934 else
15935 {
15936
2/2
✓ Branch 0 taken 33778 times.
✓ Branch 1 taken 349 times.
34127 if(x <= (int32_t)parent->x-(dmisc5*6))
15937 {
15938 349 clk3=right;
15939 349 }
15940
15941
2/2
✓ Branch 0 taken 33743 times.
✓ Branch 1 taken 384 times.
34127 if(x >= (int32_t)parent->x+(dmisc5*6))
15942 {
15943 384 clk3=left;
15944 384 }
15945
15946
4/4
✓ Branch 0 taken 23003 times.
✓ Branch 1 taken 11124 times.
✓ Branch 2 taken 21599 times.
✓ Branch 3 taken 1404 times.
34127 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15947 {
15948 1404 clk3^=1; // x jig
15949 1404 }
15950 else
15951 {
15952
4/4
✓ Branch 0 taken 11258 times.
✓ Branch 1 taken 21465 times.
✓ Branch 2 taken 10924 times.
✓ Branch 3 taken 334 times.
32723 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15953 {
15954 334 clk3^=1; // x switch back
15955 334 }
15956
15957 32723 clk2=-4;
15958 }
15959 }
15960
15961 35617 zc_swap(dir,clk3);
15962 35617 tempx = x;
15963 35617 tempy = y;
15964 35617 sprite::move(step);
15965 35617 xoffset += (x-tempx);
15966 35617 yoffset += (y-tempy);
15967 35617 zc_swap(dir,clk3);
15968
15969
2/2
✓ Branch 0 taken 106851 times.
✓ Branch 1 taken 35617 times.
142468 for(int32_t i=1; i<dmisc5; i++)
15970 {
15971 106851 nxoffset[i] = (zc_oldrand()%3);
15972 106851 nyoffset[i] = (zc_oldrand()%3);
15973 106851 }
15974 35617 }
15975
15976 156986 break;
15977
15978 case 1: // flying head
15979
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 42075 times.
44881 if(clk>=0)
15980
15981 {
15982 42075 variable_walk_8(rate,homing,hrate,spw_floater);
15983 42075 }
15984
15985 44881 break;
15986
15987 // the following are messages sent from the main guy...
15988 case -1: // got chopped off
15989 {
15990 134 misc=1;
15991 134 superman=1;
15992 134 hxofs=xofs=0;
15993 134 hit_width=16;
15994 134 cs=8;
15995 134 clk=-24;
15996 134 clk2=40;
15997 134 dir=(zc_oldrand()&7)+8;
15998 134 step=8.0/9.0;
15999 }
16000 134 break;
16001
16002 case -2: // the big guy is dead
16003 198 return true;
16004 }
16005
16006
2/2
✓ Branch 0 taken 189247 times.
✓ Branch 1 taken 12754 times.
202001 if(timer)
16007 {
16008
2/2
✓ Branch 0 taken 11233 times.
✓ Branch 1 taken 1521 times.
12754 if(!(timer%8))
16009 {
16010 1521 FireBreath(true);
16011 1521 }
16012
16013 12754 --timer;
16014 12754 }
16015
16016 202001 return enemy::animate(index);
16017 202199 }
16018
16019 3434 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
16020 {
16021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3434 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3434 if ((editorflags & ENEMY_FLAG7) && misc == 1)
16022 {
16023 int32_t wpnId = w->id;
16024
16025 if(dying)
16026 return 0;
16027
16028 switch(wpnId)
16029 {
16030 case wLitBomb:
16031 case wLitSBomb:
16032 case wBait:
16033 case wWhistle:
16034 case wFire:
16035 case wWind:
16036 case wSSparkle:
16037 case wFSparkle:
16038 case wPhantom:
16039 return 0;
16040
16041 case wHookshot:
16042 case wBrang:
16043 case wBeam:
16044 case wArrow:
16045 case wMagic:
16046 case wBomb:
16047 case wSBomb:
16048 sfx(WAV_CHINK,pan(int32_t(x)));
16049 break;
16050 default:
16051 break;
16052 }
16053
16054 return 1;
16055 }
16056 else
16057 {
16058 3434 int32_t ret = enemy::takehit(w,realweap);
16059
16060
2/2
✓ Branch 0 taken 641 times.
✓ Branch 1 taken 2793 times.
3434 if(ret==-1)
16061 2793 return 2; // force it to wait a frame before checking sword attacks again
16062
16063 641 return ret;
16064 }
16065 3434 }
16066
16067 202887 void esGleeok::draw(BITMAP *dest)
16068 {
16069 202887 dmisc5=vbound(dmisc5,1,255);
16070
16071
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 157884 times.
✓ Branch 2 taken 45003 times.
202887 switch(misc)
16072 {
16073 case 0: //neck
16074
1/2
✓ Branch 0 taken 157884 times.
✗ Branch 1 not taken.
157884 if(!dont_draw())
16075 {
16076
2/2
✓ Branch 0 taken 473652 times.
✓ Branch 1 taken 157884 times.
631536 for(int32_t i=1; i<dmisc5; i++) //draw the neck
16077 {
16078
2/2
✓ Branch 0 taken 311511 times.
✓ Branch 1 taken 162141 times.
473652 if(get_qr(qr_NEWENEMYTILES))
16079 {
16080
3/4
✓ Branch 0 taken 2211 times.
✓ Branch 1 taken 309300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2211 times.
311511 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16081 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
16082 else
16083 309300 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
16084 311511 }
16085 else
16086 {
16087
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 157863 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
162141 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16088 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
16089 else
16090 162141 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
16091 }
16092 473652 }
16093 157884 }
16094
16095 157884 break;
16096
16097 case 1: //flying head
16098 45003 tile=flyingheadtile;
16099
16100
2/2
✓ Branch 0 taken 24590 times.
✓ Branch 1 taken 20413 times.
45003 if(get_qr(qr_NEWENEMYTILES))
16101 {
16102 24590 tile+=((clk&24)>>3);
16103 24590 break;
16104 }
16105
16106 /*
16107 else
16108 {
16109 tile=(clk&1)?147:148;
16110 break;
16111 }
16112 */
16113 20413 }
16114 202887 }
16115
16116 202887 void esGleeok::draw2(BITMAP *dest)
16117 {
16118 202887 enemy::draw(dest);
16119 202887 }
16120
16121 53 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
16122 53 {
16123
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( !(editorflags & ENEMY_FLAG5) )
16124 {
16125
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 x = 128;
16126
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 y = 48;
16127 53 }
16128 else { x = X; y = Y; }
16129 53 adjusted=false;
16130
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 dir=(zc_oldrand()&7)+8;
16131 //step=0.25;
16132 53 flycnt=dmisc1;
16133 53 flycnt2=dmisc2;
16134 53 loopcnt=0;
16135 53 clk4 = 0;
16136 53 clk5 = 0;
16137 53 clk6 = 0;
16138 53 clk7 = 0;
16139
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16140 53 SIZEflags = d->SIZEflags;
16141
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16142
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16143 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16144 // al_trace("Enemy txsz:%i\n", txsz);
16145
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
16146
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
16148
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hit_width = 32;
16149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
16150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
16151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
16152
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hxofs = -8;
16153
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
16154 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16155
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
16156
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 else if (dmisc10 == 1) xofs = -8;
16157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16158 {
16159 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16160 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
16161 }
16162
1/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
16163
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (editorflags & ENEMY_FLAG8) misc = 1;
16164
16165
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
16166
16167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc29 == 0)
16168 {
16169
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16170 {
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc29 = (90 / 3);
16172 33 else dmisc29 = (84 / 3);
16173 33 }
16174 else
16175 {
16176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc29 = (90 / 2);
16177 20 else dmisc29 = (84 / 2);
16178 }
16179 53 }
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc30 == 0)
16181 {
16182
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16183 {
16184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc30 = (90 / 3)*0.5;
16185 33 else dmisc30 = (84 / 3)*0.5;
16186 33 }
16187 else
16188 {
16189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc30 = (90 / 2)*0.5;
16190 20 else dmisc30 = (84 / 2)*0.5;
16191 }
16192 53 }
16193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc31 == 0)
16194 {
16195
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16196 {
16197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc31 = (90 / 3)*2;
16198 33 else dmisc31 = (84 / 3)*2;
16199 33 }
16200 else
16201 {
16202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc31 = (90 / 2)*0.5;
16203 20 else dmisc31 = (84 / 2)*0.5;
16204 }
16205 53 }
16206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc32 == 0)
16207 {
16208
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16209 {
16210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc32 = (90 / 3);
16211 33 else dmisc32 = (84 / 3);
16212 33 }
16213 else
16214 {
16215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc32 = (90 / 2)*0.25;
16216 20 else dmisc32 = (84 / 2)*0.25;
16217 }
16218 53 }
16219 53 }
16220
16221 62362 bool ePatra::animate(int32_t index)
16222 {
16223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62362 times.
62362 if(switch_hooked) return enemy::animate(index);
16224
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 61552 times.
62362 if(dying)
16225 {
16226
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 810 times.
882 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
16227 {
16228 72 ((enemy*)guys.spr(i))->hp = -1000;
16229 72 }
16230
16231 810 return Dead(index);
16232 }
16233
16234 61552 double basesize = 84;
16235
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc10) basesize = 90;
16236 61552 double halfsize = basesize / 2;
16237 61552 double quartersize = halfsize / 2;
16238 61552 double twothirdsize = (basesize / 3)*2;
16239 61552 double onethirdsize = (basesize / 3);
16240
16241
16242
2/2
✓ Branch 0 taken 47886 times.
✓ Branch 1 taken 13666 times.
61552 if(clk==0)
16243 {
16244 13666 removearmos(x,y,ffcactivated);
16245 13666 }
16246
16247
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61552 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61552 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
16248 {
16249
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61552 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
16250
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (loopcnt < 0) ++clk2;
16251
2/2
✓ Branch 0 taken 60857 times.
✓ Branch 1 taken 695 times.
61552 if(++clk2>basesize)
16252 {
16253 695 clk2=0;
16254
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 695 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
695 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
16255 {
16256
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 334 times.
695 if(loopcnt > 0)
16257 361 --loopcnt;
16258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 else if (loopcnt == 0)
16259 {
16260
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 128 times.
334 if((misc%dmisc6)==0)
16261 {
16262
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (dmisc21 > 0) loopcnt=-dmisc21;
16263 128 else loopcnt=dmisc7;
16264 128 }
16265 334 }
16266 else if (loopcnt == -1) loopcnt=dmisc7;
16267 else ++loopcnt;
16268
16269
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
695 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
16270 695 }
16271 else
16272 {
16273 loopcnt = 0;
16274 misc = 1;
16275 }
16276 695 }
16277 61552 }
16278
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk4 > 0) --clk4;
16279
16280
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 < 0)
16281 {
16282 if (dmisc5 == 1 || dmisc5 == 3)
16283 {
16284 if (get_qr(qr_NEWENEMYTILES))
16285 {
16286 if (clk7 <= 0 || clk6 != -16) ++clk6;
16287 if (clk6 == 0) o_tile=d->e_tile;
16288 else
16289 {
16290 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
16291 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
16292 }
16293 }
16294 else clk6 = 0;
16295 }
16296 }
16297
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk6;
16298
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk5 < 0) ++clk5;
16299
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk5;
16300
16301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61552 if (clk7 > 0 && clk6 >= -16) --clk7;
16302
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 > 0) clk7 = 0;
16303
16304
2/2
✓ Branch 0 taken 244144 times.
✓ Branch 1 taken 61552 times.
305696 for(int32_t i=index+1; i<index+flycnt+1; i++)
16305 {
16306 //outside ring
16307
2/2
✓ Branch 0 taken 243720 times.
✓ Branch 1 taken 424 times.
244144 if(!adjusted)
16308 {
16309
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 152 times.
424 if(get_qr(qr_NEWENEMYTILES))
16310 {
16311 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
16312 272 enemy *s = ((enemy*)guys.spr(i));
16313 272 s->parent_script_UID = this->script_UID;
16314 272 }
16315 else
16316 {
16317 152 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16318 152 enemy *s = ((enemy*)guys.spr(i));
16319 152 s->parent_script_UID = this->script_UID;
16320 }
16321
16322 424 ((enemy*)guys.spr(i))->cs=dmisc9;
16323 424 ((enemy*)guys.spr(i))->hp=dmisc3;
16324 424 }
16325
16326
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 243783 times.
244144 if(((enemy*)guys.spr(i))->hp <= 0)
16327 {
16328
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 361 times.
1655 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16329 {
16330 1294 guys.swap(j,j+1);
16331 1294 }
16332
16333
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
361 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
16334 361 }
16335 else
16336 {
16337 243783 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16338
1/2
✓ Branch 0 taken 243783 times.
✗ Branch 1 not taken.
243783 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
16339
16340
2/2
✓ Branch 0 taken 86967 times.
✓ Branch 1 taken 156816 times.
243783 if(!dmisc4) //Big Ring
16341 {
16342 //maybe playing_field_offset here?
16343
2/2
✓ Branch 0 taken 84872 times.
✓ Branch 1 taken 71944 times.
156816 if(loopcnt>0)
16344 {
16345
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16346
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16347 84872 }
16348 else
16349 {
16350 71944 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16351 71944 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16352 }
16353
16354 156816 temp_x=guys.spr(i)->x;
16355 156816 temp_y=guys.spr(i)->y;
16356 156816 }
16357 else //Oval
16358 {
16359 86967 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16360 86967 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16361
16362
2/2
✓ Branch 0 taken 50142 times.
✓ Branch 1 taken 36825 times.
86967 if(loopcnt>0)
16363 {
16364 50142 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16365
1/2
✓ Branch 0 taken 50142 times.
✗ Branch 1 not taken.
50142 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
16366 50142 }
16367 else
16368 {
16369 36825 guys.spr(i)->x = circle_x;
16370 36825 guys.spr(i)->y = circle_y;
16371 }
16372
16373 86967 temp_x=circle_x;
16374 86967 temp_y=circle_y;
16375 }
16376
16377 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16378 243783 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16379
16380
4/4
✓ Branch 0 taken 46216 times.
✓ Branch 1 taken 197567 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30939 times.
243783 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16381 {
16382 30939 guys.spr(i)->dir=l_down;
16383 30939 }
16384
4/4
✓ Branch 0 taken 46264 times.
✓ Branch 1 taken 166580 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30987 times.
212844 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16385 {
16386 30987 guys.spr(i)->dir=left;
16387 30987 }
16388
4/4
✓ Branch 0 taken 45998 times.
✓ Branch 1 taken 135859 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30721 times.
181857 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16389 {
16390 30721 guys.spr(i)->dir=l_up;
16391 30721 }
16392
4/4
✓ Branch 0 taken 45644 times.
✓ Branch 1 taken 105492 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30367 times.
151136 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16393 {
16394 30367 guys.spr(i)->dir=up;
16395 30367 }
16396
4/4
✓ Branch 0 taken 45419 times.
✓ Branch 1 taken 75350 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30142 times.
120769 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16397 {
16398 30142 guys.spr(i)->dir=r_up;
16399 30142 }
16400
4/4
✓ Branch 0 taken 45271 times.
✓ Branch 1 taken 45356 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 29994 times.
90627 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16401 {
16402 29994 guys.spr(i)->dir=right;
16403 29994 }
16404
4/4
✓ Branch 0 taken 45354 times.
✓ Branch 1 taken 15279 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30077 times.
60633 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16405 {
16406 30077 guys.spr(i)->dir=r_down;
16407 30077 }
16408 else
16409 {
16410 30556 guys.spr(i)->dir=down;
16411 }
16412
16413 243783 guys.spr(i)->x += x;
16414 243783 guys.spr(i)->y += y;
16415 }
16416 244144 }
16417
16418
7/22
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39936 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
61552 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
16419 {
16420 15803 int timeneeded = 48;
16421 15803 int patbreath = (zc_oldrand()%50+50);
16422
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
16423
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
16424 {
16425 timeneeded = 48 + patbreath;
16426 }
16427
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
16428 {
16429 timeneeded = 48 + 96;
16430 }
16431
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
16432
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
16433
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16434 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
16435 133 && (clk6 >= 0) //if not in the middle of firing...
16436 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
16437
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
16438 {
16439
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
16440 {
16441 case patratSTREAM:
16442 {
16443 clk7 = 97;
16444 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16445 else clk6 = 0;
16446 break;
16447 }
16448 case patratBREATH:
16449 {
16450 clk7 = patbreath;
16451 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16452 else clk6 = 0;
16453 break;
16454 }
16455 default:
16456 {
16457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16458 {
16459 clk6 = -48;
16460 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16461 }
16462 else
16463 {
16464 133 clk6 = 0;
16465
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16466 133 FirePatraWeapon();
16467 }
16468 133 break;
16469 }
16470 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16471 133 }
16472
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
16473 {
16474 switch(dmisc28)
16475 {
16476 case patratSTREAM:
16477 {
16478 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
16479 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16480 break;
16481 }
16482 case patratBREATH:
16483 {
16484 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
16485 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16486 break;
16487 }
16488 default:
16489 {
16490 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
16491 {
16492 FirePatraWeapon();
16493 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16494 }
16495 break;
16496 }
16497 }
16498 }
16499 15803 }
16500
16501 61552 int randattempts = 0;
16502 61552 int randeye = 0;
16503
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if (flycnt2 > 0)
16504 {
16505 16602 do
16506 {
16507
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✓ Branch 2 taken 15935 times.
✓ Branch 3 taken 667 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16508 16602 randeye += (index + flycnt + 1);
16509 16602 ++randattempts;
16510
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16511 16602 }
16512 61552 bool dofire = false;
16513
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc20)
16514 {
16515 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16516 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16517 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16518 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16519 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16520 {
16521 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16522 {
16523 if (clk5 >= dmisc19)
16524 {
16525 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16526 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16527 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16528 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16529 || dmisc18 == -1)
16530 dofire = true;
16531 }
16532 }
16533 }
16534 }
16535
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if(flycnt2)
16536 {
16537
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16538 {
16539
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
16540 {
16541 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16542
16543
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_qr(qr_NEWENEMYTILES))
16544 {
16545
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16546 {
16547
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
16548 {
16549 // Center eye shoots projectiles; make room for its firing tiles
16550 case 1:
16551 case 3:
16552 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16553 48 break;
16554
16555 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16556 default:
16557 case 2:
16558 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16559 40 break;
16560 }
16561 88 }
16562 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16563 88 }
16564 else
16565 {
16566 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16567 }
16568
16569 88 ((enemy*)guys.spr(i))->cs=dmisc9;
16570
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16571 88 }
16572
16573
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
16574 {
16575 94136 ((enemy*)guys.spr(i))->superman=true;
16576 94136 }
16577 else
16578 {
16579 25839 ((enemy*)guys.spr(i))->superman=false;
16580 }
16581
16582
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
16583 {
16584
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16585 {
16586 144 guys.swap(j,j+1);
16587 144 }
16588
16589
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16590 72 }
16591 else
16592 {
16593 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16594
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16595
16596
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
16597 {
16598
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
16599 {
16600
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16601
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16602 58268 }
16603 else
16604 {
16605 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16606 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16607 }
16608
16609 112644 temp_x=guys.spr(i)->x;
16610 112644 temp_y=guys.spr(i)->y;
16611 112644 }
16612 else
16613 {
16614 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16615 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16616
16617
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16618 {
16619 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16620
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16621 3965 }
16622 else
16623 {
16624 3294 guys.spr(i)->x = circle_x;
16625 3294 guys.spr(i)->y = circle_y;
16626 }
16627
16628 7259 temp_x=circle_x;
16629 7259 temp_y=circle_y;
16630 }
16631
16632 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16633 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16634
16635
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16636 {
16637 14941 guys.spr(i)->dir=l_down;
16638 14941 }
16639
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16640 {
16641 14928 guys.spr(i)->dir=left;
16642 14928 }
16643
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16644 {
16645 14937 guys.spr(i)->dir=l_up;
16646 14937 }
16647
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16648 {
16649 14996 guys.spr(i)->dir=up;
16650 14996 }
16651
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16652 {
16653 15041 guys.spr(i)->dir=r_up;
16654 15041 }
16655
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16656 {
16657 15035 guys.spr(i)->dir=right;
16658 15035 }
16659
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16660 {
16661 15035 guys.spr(i)->dir=r_down;
16662 15035 }
16663 else
16664 {
16665 14990 guys.spr(i)->dir=down;
16666 }
16667
16668 119903 guys.spr(i)->x += x;
16669 119903 guys.spr(i)->y = y-guys.spr(i)->y;
16670
16671
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16672 {
16673 /*
16674 if(!(zc_oldrand()&127))
16675 {
16676 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16677 sfx(wpnsfx(wpn),pan(int32_t(x)));
16678 }
16679 */
16680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16681 {
16682 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16683 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16684 {
16685 if (dmisc5 == 3)
16686 {
16687 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16688 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16689 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16690 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16691 }
16692 else
16693 {
16694 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16695 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16696 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16697 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16698 }
16699 }
16700 else
16701 {
16702 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16703 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16704 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16705 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16706 }
16707 }
16708
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16709
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16710
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16711 {
16712
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
16713 {
16714 case 4: //Single one rapidfires
16715 {
16716 if (dofire && i == randeye)
16717 {
16718 ((esPatra*)guys.spr(i))->clk5 = -16;
16719 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16720 ((esPatra*)guys.spr(i))->clk4 = 96;
16721 clk5 = -3;
16722 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16723 }
16724 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16725 {
16726 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16727 sfx(wpnsfx(wpn),pan(int32_t(x)));
16728 }
16729 break;
16730 }
16731 case 3: //Ring
16732 {
16733 if (dofire)
16734 {
16735 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16736 {
16737 ((esPatra*)guys.spr(i))->clk5 = -48;
16738 clk5 = -48;
16739 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16740 }
16741 else
16742 {
16743 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16744 sfx(wpnsfx(wpn),pan(int32_t(x)));
16745 int32_t m=Ewpns.Count()-1;
16746 weapon *ew = (weapon*)(Ewpns.spr(m));
16747
16748 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16749 ((esPatra*)guys.spr(i))->clk5 = 0;
16750 clk5 = 0;
16751 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16752 }
16753 }
16754 if (((esPatra*)guys.spr(i))->clk5 == -16)
16755 {
16756 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16757 sfx(wpnsfx(wpn),pan(int32_t(x)));
16758 int32_t m=Ewpns.Count()-1;
16759 weapon *ew = (weapon*)(Ewpns.spr(m));
16760
16761 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16762 }
16763 break;
16764 }
16765 case 2: //one after another
16766 {
16767 if (dofire)
16768 {
16769 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16770 clk5 = -48 - (12*flycnt2);
16771 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16772 }
16773 if (((esPatra*)guys.spr(i))->clk5 == -16)
16774 {
16775 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16776 sfx(wpnsfx(wpn),pan(int32_t(x)));
16777 }
16778 break;
16779 }
16780 case 1: //random one eye
16781 {
16782 if (dofire && i == randeye)
16783 {
16784 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16785 {
16786 ((esPatra*)guys.spr(i))->clk5 = -48;
16787 clk5 = -48;
16788 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16789 }
16790 else
16791 {
16792 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16793 sfx(wpnsfx(wpn),pan(int32_t(x)));
16794 ((esPatra*)guys.spr(i))->clk5 = 0;
16795 clk5 = 0;
16796 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16797 }
16798 }
16799 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16800 {
16801 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16802 sfx(wpnsfx(wpn),pan(int32_t(x)));
16803 }
16804 break;
16805 }
16806 default: //old behavior, all eyes can fire any time
16807 {
16808
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16809
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16811 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16812 {
16813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16814 {
16815 ((esPatra*)guys.spr(i))->clk5 = -48;
16816 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16817 }
16818 else
16819 {
16820 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16821 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
16822 292 ((esPatra*)guys.spr(i))->clk5 = 0;
16823
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16824 }
16825 292 }
16826
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16827 {
16828 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16829 sfx(wpnsfx(wpn),pan(int32_t(x)));
16830 }
16831 38077 break;
16832 }
16833 }
16834 38077 }
16835 38077 }
16836
16837 }
16838 119975 }
16839 16602 }
16840
16841 61552 adjusted=true;
16842 61552 return enemy::animate(index);
16843 62362 }
16844
16845 133 void ePatra::FirePatraWeapon()
16846 { //.707
16847 133 int32_t xoff = 0;
16848 133 int32_t yoff = 0;
16849
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16850 {
16851 xoff += (hit_width/2)-8;
16852 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16853 }
16854
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16855 {
16856 yoff += (hit_height/2)-8;
16857 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16858 }
16859 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16860
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
16861 {
16862 case patrat8SHOT: //Fire Wizzrobe
16863 case patrat4SHOTDIAG:
16864 case patrat4SHOTRAND:
16865 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16866 {
16867 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16868 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16869 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16870 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16871
16872 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16873 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16875 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16876
16877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16879 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16880 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16881
16882 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16883 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16884 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16885 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16886
16887 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16888 }
16889
16890 [[fallthrough]];
16891 case patrat4SHOTCARD: //Stalfos 3
16892 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16893 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16894 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16895 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16896 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16897 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16898 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16899 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16900 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16901 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16902 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16903 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16904 break;
16905
16906 default:
16907 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16908
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16909 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16910
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16911
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16912 {
16913 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16914 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16916 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16917 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16918 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16919 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16920 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16921 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16922 {
16923 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16924 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16925 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16926 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16927 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16928 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16929 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16930 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16931 }
16932 }
16933 133 break;
16934
16935 }
16936 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16937 //+0.46364761
16938 //11.80
16939 133 }
16940
16941 124918 void ePatra::draw(BITMAP *dest)
16942 {
16943 124918 tile=o_tile;
16944 124918 update_enemy_frame();
16945 124918 enemy::draw(dest);
16946 124918 }
16947
16948 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16949 {
16950 int32_t ret = enemy::defend(wpnId, power, edef);
16951
16952 if(ret < 0 && (flycnt||flycnt2))
16953 return 0;
16954
16955 return ret;
16956 }
16957
16958 908 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16959 {
16960 908 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16961
16962
6/6
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 408 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 145 times.
908 if(ret < 0 && (flycnt||flycnt2))
16963 660 return 0;
16964
16965 248 return ret;
16966 908 }
16967
16968 1024 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16969 512 {
16970 //cs=8;
16971 512 item_set=0;
16972 512 misc=clk;
16973 512 clk4 = 0;
16974 512 clk5 = 0;
16975 512 clk = -((misc*21)>>1)-1;
16976
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16977 512 hit_width=12;
16978 512 hit_height=12;
16979 512 hxofs=2;
16980 512 hyofs=2;
16981 512 extend = 0;
16982 512 txsz = 1;
16983 512 tysz = 1;
16984 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16985 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16986 int32_t prntSIZEflags = prntenemy->SIZEflags;
16987 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16988 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16989 // al_trace("Enemy txsz:%i\n", txsz);
16990 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16991 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16992 else
16993 hxsz=12;
16994 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16995 else
16996 hysz=12;
16997 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16998 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16999 else
17000 hxofs=2;
17001 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17002 else hyofs=2;
17003 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17004 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17005 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17006 {
17007 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17008 }
17009
17010 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
17011 */
17012 512 mainguy=count_enemy=false;
17013 512 bgsfx=-1;
17014 //o_tile=0;
17015 512 flags &= (~guy_neverret);
17016 512 deadsfx = WAV_EDEAD;
17017 512 hitsfx = WAV_EHIT;
17018 512 isCore = false;
17019 512 }
17020
17021 372279 bool esPatra::animate(int32_t index)
17022 {
17023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372279 times.
372279 if(switch_hooked) return enemy::animate(index);
17024
2/2
✓ Branch 0 taken 7866 times.
✓ Branch 1 taken 364413 times.
372279 if(dying)
17025 7866 return Dead(index);
17026
17027 364413 return enemy::animate(index);
17028 372279 }
17029
17030 747310 void esPatra::draw(BITMAP *dest)
17031 {
17032
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 202590 times.
747310 if(get_qr(qr_NEWENEMYTILES))
17033 {
17034 544720 tile = o_tile+(clk&3);
17035
17036
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
17037 {
17038 case up: //u
17039 67770 flip=0;
17040 67770 break;
17041
17042 case down: //d
17043 69066 flip=0;
17044 69066 tile+=4;
17045 69066 break;
17046
17047 case left: //l
17048 67800 flip=0;
17049 67800 tile+=8;
17050 67800 break;
17051
17052 case right: //r
17053 67996 flip=0;
17054 67996 tile+=12;
17055 67996 break;
17056
17057 case l_up: //ul
17058 67484 flip=0;
17059 67484 tile+=20;
17060 67484 break;
17061
17062 case r_up: //ur
17063 68044 flip=0;
17064 68044 tile+=24;
17065 68044 break;
17066
17067 case l_down: //dl
17068 68474 flip=0;
17069 68474 tile+=28;
17070 68474 break;
17071
17072 case r_down: //dr
17073 68086 flip=0;
17074 68086 tile+=32;
17075 68086 break;
17076 }
17077 544720 }
17078 else
17079 {
17080 202590 tile = o_tile+((clk&2)>>1);
17081 }
17082
17083
2/2
✓ Branch 0 taken 38248 times.
✓ Branch 1 taken 709062 times.
747310 if(clk>=0)
17084 709062 enemy::draw(dest);
17085 747310 }
17086
17087
17088 3 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
17089 3 {
17090 3 adjusted=false;
17091
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
17092
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
17093 3 clk4 = 0;
17094 3 clk5 = 0;
17095 //flycnt=6; flycnt2=0;
17096 3 flycnt=dmisc1;
17097 3 flycnt2=0; // PatraBS doesn't have inner rings!
17098 3 loopcnt=0;
17099
17100 3 SIZEflags = d->SIZEflags;
17101
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17102 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17103 // al_trace("Enemy txsz:%i\n", txsz);
17104
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
17106 3 else hit_width = 32;
17107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
17108
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17110 3 else hxofs=-8;
17111
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17112 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17113
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
17114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17115 {
17116 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17117 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
17118 }
17119
17120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
17121
17122
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
17123
17124 //nets+4480;
17125 3 }
17126
17127 1862 bool ePatraBS::animate(int32_t index)
17128 {
17129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
17130
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
17131 54 return Dead(index);
17132
17133
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
17134 {
17135 442 removearmos(x,y,ffcactivated);
17136 442 }
17137
17138 1808 variable_walk_8(rate,homing,hrate,spw_floater);
17139
17140
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
17141 {
17142 19 clk2=0;
17143
17144
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
17145 12 --loopcnt;
17146 else
17147 {
17148
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
17149 4 loopcnt=dmisc7;
17150 }
17151
17152 19 ++misc;
17153 19 }
17154
17155 // double size=1;;
17156
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
17157 {
17158
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
17159 {
17160 18 ((enemy*)guys.spr(i))->hp=dmisc3;
17161
17162
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_qr(qr_NEWENEMYTILES))
17163 {
17164 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
17165 18 }
17166 else
17167 {
17168 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
17169 }
17170
17171 18 ((enemy*)guys.spr(i))->cs = dmisc9;
17172 18 }
17173
17174
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
17175 {
17176
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
17177 {
17178 26 guys.swap(j,j+1);
17179 26 }
17180
17181 18 --flycnt;
17182 18 }
17183 else
17184 {
17185 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
17186
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
17187 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
17188 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
17189
17190
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
17191 {
17192 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
17193
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
17194 2305 }
17195 else
17196 {
17197 2132 guys.spr(i)->x = temp_x;
17198 2132 guys.spr(i)->y = temp_y;
17199 }
17200
17201 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17202 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
17203
17204
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17205 {
17206 551 guys.spr(i)->dir=l_down;
17207 551 }
17208
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17209 {
17210 534 guys.spr(i)->dir=left;
17211 534 }
17212
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17213 {
17214 522 guys.spr(i)->dir=l_up;
17215 522 }
17216
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17217 {
17218 564 guys.spr(i)->dir=up;
17219 564 }
17220
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17221 {
17222 545 guys.spr(i)->dir=r_up;
17223 545 }
17224
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17225 {
17226 562 guys.spr(i)->dir=right;
17227 562 }
17228
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17229 {
17230 554 guys.spr(i)->dir=r_down;
17231 554 }
17232 else
17233 {
17234 605 guys.spr(i)->dir=down;
17235 }
17236
17237 4437 guys.spr(i)->x += x;
17238 4437 guys.spr(i)->y += y;
17239 }
17240 4455 }
17241
17242 1808 adjusted=true;
17243 1808 return enemy::animate(index);
17244 1862 }
17245
17246 3724 void ePatraBS::draw(BITMAP *dest)
17247 {
17248 3724 tile=o_tile;
17249
17250
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_qr(qr_NEWENEMYTILES))
17251 {
17252 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17253 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
17254
17255
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17256 {
17257 102 lookat=l_down;
17258 102 }
17259
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17260 {
17261 310 lookat=down;
17262 310 }
17263
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17264 {
17265 952 lookat=r_down;
17266 952 }
17267
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17268 {
17269 1686 lookat=right;
17270 1686 }
17271
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17272 {
17273 180 lookat=r_up;
17274 180 }
17275
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17276 {
17277 lookat=up;
17278 }
17279
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 302 times.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17280 {
17281 lookat=l_up;
17282 }
17283 else
17284 {
17285 494 lookat=left;
17286 }
17287
17288
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
17289 {
17290 case up: //u
17291 flip=0;
17292 break;
17293
17294 case down: //d
17295 310 flip=0;
17296 310 tile+=8;
17297 310 break;
17298
17299 case left: //l
17300 494 flip=0;
17301 494 tile+=40;
17302 494 break;
17303
17304 case right: //r
17305 1686 flip=0;
17306 1686 tile+=48;
17307 1686 break;
17308
17309 case l_up: //ul
17310 flip=0;
17311 tile+=80;
17312 break;
17313
17314 case r_up: //ur
17315 180 flip=0;
17316 180 tile+=88;
17317 180 break;
17318
17319 case l_down: //dl
17320 102 flip=0;
17321 102 tile+=120;
17322 102 break;
17323
17324 case r_down: //dr
17325 952 flip=0;
17326 952 tile+=128;
17327 952 break;
17328 }
17329
17330 3724 tile+=(2*(clk&3));
17331 3724 xofs-=8;
17332 3724 yofs-=8;
17333 3724 drawblock(dest,15);
17334 3724 xofs+=8;
17335 3724 yofs+=8;
17336 3724 }
17337 else
17338 {
17339 flip=(clk&1);
17340 xofs-=8;
17341 yofs-=8;
17342 enemy::draw(dest);
17343 xofs+=16;
17344 enemy::draw(dest);
17345 yofs+=16;
17346 enemy::draw(dest);
17347 xofs-=16;
17348 enemy::draw(dest);
17349 xofs+=8;
17350 yofs-=8;
17351 }
17352 3724 }
17353
17354 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
17355 {
17356 int32_t ret = enemy::defend(wpnId, power, edef);
17357
17358 if(ret < 0 && (flycnt||flycnt2))
17359 return 0;
17360
17361 return ret;
17362 }
17363
17364 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
17365 {
17366 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
17367
17368
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
17369 19 return 0;
17370
17371 6 return ret;
17372 25 }
17373
17374 36 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17375 18 {
17376 //cs=csBOSS;
17377 18 item_set=0;
17378 18 misc=clk;
17379 18 clk = -((misc*21)>>1)-1;
17380 18 clk4 = 0;
17381 18 clk5 = 0;
17382
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
17383 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
17384
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17385 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17386 // al_trace("Enemy txsz:%i\n", txsz);
17387
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
17388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
17389 18 else hit_width=16;
17390
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
17391 18 else hit_height=16;
17392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
17393
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
17394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17395 18 else hyofs=2;
17396 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17397
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17399 {
17400 yofs = (int32_t)prntenemy->yofs;
17401 }
17402
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17403
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
17404
17405 18 bgsfx=-1;
17406 18 mainguy=count_enemy=false;
17407 18 deadsfx = WAV_EDEAD;
17408 18 hitsfx = WAV_EHIT;
17409 18 flags &= ~guy_neverret;
17410 18 isCore = false;
17411 18 }
17412
17413 4790 bool esPatraBS::animate(int32_t index)
17414 {
17415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
17416
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
17417 324 return Dead(index);
17418
17419 4466 return enemy::animate(index);
17420 4790 }
17421
17422 9580 void esPatraBS::draw(BITMAP *dest)
17423 {
17424 9580 tile=o_tile;
17425
17426
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_qr(qr_NEWENEMYTILES))
17427 {
17428
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
17429 {
17430 case up: //u
17431 1280 flip=0;
17432 1280 break;
17433
17434 case down: //d
17435 1326 flip=0;
17436 1326 tile+=4;
17437 1326 break;
17438
17439 case left: //l
17440 1076 flip=0;
17441 1076 tile+=8;
17442 1076 break;
17443
17444 case right: //r
17445 1254 flip=0;
17446 1254 tile+=12;
17447 1254 break;
17448
17449 case l_up: //ul
17450 1080 flip=0;
17451 1080 tile+=20;
17452 1080 break;
17453
17454 case r_up: //ur
17455 1238 flip=0;
17456 1238 tile+=24;
17457 1238 break;
17458
17459 case l_down: //dl
17460 1146 flip=0;
17461 1146 tile+=28;
17462 1146 break;
17463
17464 case r_down: //dr
17465 1180 flip=0;
17466 1180 tile+=32;
17467 1180 break;
17468 }
17469
17470 9580 tile += ((clk&6)>>1);
17471 9580 }
17472 else
17473 {
17474 tile += (clk&4)?1:0;
17475 }
17476
17477
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
17478 8608 enemy::draw(dest);
17479 9580 }
17480
17481
17482 /**********************************/
17483 /********** Misc Code ***********/
17484 /**********************************/
17485
17486 162470 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17487 {
17488
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 40366 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
162470 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17489
4/8
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162470 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162470 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162470 times.
✗ Branch 7 not taken.
162470 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17490
1/2
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
162470 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17491 162470 }
17492
17493 36428 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17494 {
17495 // Kludge
17496
4/8
✓ Branch 0 taken 36428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36428 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36428 times.
✗ Branch 7 not taken.
36428 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17497 36428 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36428 times.
36428 delete w;
17499 36428 return ret;
17500 }
17501
17502 4228 void enemy_scored(int32_t index)
17503 {
17504 4228 ((enemy*)guys.spr(index))->scored=true;
17505 4228 }
17506
17507 1440 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17508 {
17509
6/10
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115 times.
✓ Branch 7 taken 1325 times.
✓ Branch 8 taken 1440 times.
✗ Branch 9 not taken.
1440 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17510
3/6
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1440 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17511 {
17512 g->o_tile = parentscr->guytile;
17513 if(g->o_tile != 0)
17514 g->flags &= ~guy_invisible;
17515 g->cs = parentscr->guycs;
17516 }
17517 1440 guys.add(g);
17518 1440 }
17519
17520 22137 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17521 {
17522
4/8
✓ Branch 0 taken 22137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22137 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22137 times.
✗ Branch 7 not taken.
22137 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17523 22137 items.add(i);
17524 22137 }
17525
17526 80 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17527 {
17528
5/10
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 80 times.
✗ Branch 9 not taken.
80 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17529 80 items.add(i);
17530 80 }
17531
17532 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17533 {
17534 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17535 items.add(i);
17536 }
17537
17538 79 void kill_em_all()
17539 {
17540
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 79 times.
375 for(int32_t i=0; i<guys.Count(); i++)
17541 {
17542 296 enemy *e = ((enemy*)guys.spr(i));
17543
17544
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
296 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17545
17546 271 e->kickbucket();
17547 271 }
17548 79 }
17549
17550 bool can_kill_em_all()
17551 {
17552 for(int32_t i=0; i<guys.Count(); i++)
17553 {
17554 enemy *e = ((enemy*)guys.spr(i));
17555
17556 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17557 if(e->superman) continue;
17558 return true;
17559 }
17560 return false;
17561 }
17562
17563 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17564 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17565 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17566 {
17567 for(int32_t i=0; i<guys.Count(); i++)
17568 {
17569 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17570 {
17571 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17572 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17573 {
17574 return i;
17575 }
17576 }
17577 }
17578
17579 return -1;
17580 }
17581
17582 6674530 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17583 {
17584
4/4
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 6665836 times.
✓ Branch 2 taken 19149455 times.
✓ Branch 3 taken 6657246 times.
25806701 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17585 {
17586
2/2
✓ Branch 0 taken 17284 times.
✓ Branch 1 taken 19132171 times.
19149455 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17587 {
17588 17284 return i;
17589 }
17590 19132171 }
17591
17592 6657246 return -1;
17593 6674530 }
17594
17595 // For Hero's hit detection. Count them if they are dying.
17596 27398 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17597 {
17598 27398 enemy *e = (enemy*)guys.spr(index);
17599
3/4
✓ Branch 0 taken 27398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14844 times.
✓ Branch 3 taken 12554 times.
27398 if(!e || e->hp > 0)
17600 14844 return -1;
17601
17602 12554 bool d = e->dying;
17603 12554 int32_t hc = e->hclk;
17604 12554 e->dying = false;
17605 12554 e->hclk = 0;
17606 12554 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17607 12554 e->dying = d;
17608 12554 e->hclk = hc;
17609
17610
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 12433 times.
12554 return hit ? index : -1;
17611 27398 }
17612
17613 7287641 bool hasMainGuy()
17614 {
17615
2/2
✓ Branch 0 taken 8741411 times.
✓ Branch 1 taken 2591179 times.
11332590 for(int32_t i=0; i<guys.Count(); i++)
17616 {
17617
2/2
✓ Branch 0 taken 4696462 times.
✓ Branch 1 taken 4044949 times.
8741411 if(((enemy*)guys.spr(i))->mainguy)
17618 {
17619 4696462 return true;
17620 }
17621 4044949 }
17622
17623 2591179 return false;
17624 7287641 }
17625
17626 51 void EatHero(int32_t index)
17627 {
17628 51 ((eStalfos*)guys.spr(index))->eathero();
17629 51 }
17630
17631 3 void GrabHero(int32_t index)
17632 {
17633 3 ((eWallM*)guys.spr(index))->grabhero();
17634 3 }
17635
17636 292 bool CarryHero()
17637 {
17638
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
17639 {
17640
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17641 {
17642
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
17643 {
17644 292 Hero.x=guys.spr(i)->x;
17645 292 Hero.y=guys.spr(i)->y;
17646 292 return ((eWallM*)guys.spr(i))->misc > 0;
17647 }
17648 63 }
17649
17650 // Like Likes currently can't carry Hero.
17651 /*
17652 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17653 {
17654 if(((eLikeLike*)guys.spr(i))->hashero)
17655 {
17656 Hero.x=guys.spr(i)->x;
17657 Hero.y=guys.spr(i)->y;
17658 return (true);
17659 }
17660 }*/
17661 599 }
17662
17663 return false;
17664 292 }
17665
17666 // Move item with guy
17667 void movefairy(zfix &x,zfix &y,int32_t misc)
17668 {
17669 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17670
17671 if(i!=-1)
17672 {
17673 x = guys.spr(i)->x;
17674 y = guys.spr(i)->y;
17675 }
17676 }
17677
17678 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17679 void movefairy2(zfix x,zfix y,int32_t misc)
17680 {
17681 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17682
17683 if(i!=-1)
17684 {
17685 guys.spr(i)->x = x;
17686 guys.spr(i)->y = y;
17687 }
17688 }// Move item with guy
17689
17690 33988 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17691 {
17692 33988 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17693
17694
1/2
✓ Branch 0 taken 33988 times.
✗ Branch 1 not taken.
33988 if(fairy)
17695 {
17696 33988 x = fairy->x;
17697 33988 y = fairy->y;
17698 33988 }
17699 33988 }
17700
17701 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17702 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17703 {
17704 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17705
17706 if(fairy)
17707 {
17708 fairy->x = x;
17709 fairy->y = y;
17710 }
17711 }
17712
17713 void killfairy(int32_t misc)
17714 {
17715 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17716 guys.del(i);
17717 }
17718
17719 int32_t getGuyIndex(const int32_t eid)
17720 {
17721 for(word i = 0; i < guys.Count(); i++)
17722 {
17723 if(guys.spr(i)->getUID() == eid)
17724 return i;
17725 }
17726
17727 return -1;
17728 }
17729
17730 void killfairynew(item const &itemfairy)
17731 {
17732 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17733 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17734 }
17735
17736 //Should probably change this to return an 'enemy*', null on failure -Em
17737 13284 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17738 {
17739 13284 return addenemy(x,y,0,id,clk);
17740 }
17741
17742 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17743 {
17744 868 return addchild(x,y,0,id,clk, parent_scriptUID);
17745 }
17746
17747 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17748 {
17749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
17750
17751 893 int32_t ret = 0;
17752 893 sprite *e=NULL;
17753 893 al_trace("Adding child\n");
17754
17755
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
17756 {
17757 //Fixme: possible enemy memory leak. (minor)
17758 case eeWALK:
17759
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17760 16 break;
17761
17762 case eeLEV:
17763 e = new eLeever((zfix)x,(zfix)y,id,clk);
17764 break;
17765
17766 case eeTEK:
17767 e = new eTektite((zfix)x,(zfix)y,id,clk);
17768 break;
17769
17770 case eePEAHAT:
17771 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17772 break;
17773
17774 case eeZORA:
17775 e = new eZora((zfix)x,(zfix)y,id,clk);
17776 break;
17777
17778 case eeGHINI:
17779 e = new eGhini((zfix)x,(zfix)y,id,clk);
17780 break;
17781
17782 case eeKEESE:
17783
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
17784 857 break;
17785
17786 case eeWIZZ:
17787
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17788 15 break;
17789
17790 case eePROJECTILE:
17791 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17792 break;
17793
17794 case eeWALLM:
17795 e = new eWallM((zfix)x,(zfix)y,id,clk);
17796 break;
17797
17798 case eeAQUA:
17799 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17800 break;
17801
17802 case eeMOLD:
17803 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17804 break;
17805
17806 case eeMANHAN:
17807
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17808 1 break;
17809
17810 case eeGLEEOK:
17811 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17812 break;
17813
17814 case eeGHOMA:
17815 e = new eGohma((zfix)x,(zfix)y,id,clk);
17816 break;
17817
17818 case eeLANM:
17819 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
17820 break;
17821
17822 case eeGANON:
17823 e = new eGanon((zfix)x,(zfix)y,id,clk);
17824 break;
17825
17826 case eeFAIRY:
17827 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17828 break;
17829
17830 case eeFIRE:
17831 e = new eFire((zfix)x,(zfix)y,id,clk);
17832 break;
17833
17834 case eeOTHER:
17835 e = new eOther((zfix)x,(zfix)y,id,clk);
17836 break;
17837
17838
17839 case eeSCRIPT01:
17840 case eeSCRIPT02:
17841 case eeSCRIPT03:
17842 case eeSCRIPT04:
17843 case eeSCRIPT05:
17844 case eeSCRIPT06:
17845 case eeSCRIPT07:
17846 case eeSCRIPT08:
17847 case eeSCRIPT09:
17848 case eeSCRIPT10:
17849 case eeSCRIPT11:
17850 case eeSCRIPT12:
17851 case eeSCRIPT13:
17852 case eeSCRIPT14:
17853 case eeSCRIPT15:
17854 case eeSCRIPT16:
17855 case eeSCRIPT17:
17856 case eeSCRIPT18:
17857 case eeSCRIPT19:
17858 case eeSCRIPT20:
17859 {
17860 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17861 {
17862 e = new eScript((zfix)x,(zfix)y,id,clk);
17863 break;
17864 }
17865 else return 0;
17866 }
17867
17868 case eeFFRIENDLY01:
17869 case eeFFRIENDLY02:
17870 case eeFFRIENDLY03:
17871 case eeFFRIENDLY04:
17872 case eeFFRIENDLY05:
17873 case eeFFRIENDLY06:
17874 case eeFFRIENDLY07:
17875 case eeFFRIENDLY08:
17876 case eeFFRIENDLY09:
17877 case eeFFRIENDLY10:
17878 {
17879 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17880 {
17881 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17882 }
17883 else return 0;
17884
17885 }
17886
17887 case eeSPINTILE:
17888 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17889 break;
17890
17891 // and these enemies use the misc10/misc2 value
17892 case eeROCK:
17893 {
17894 switch(guysbuf[id&0xFFF].misc10)
17895 {
17896 case 1:
17897 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17898 break;
17899
17900 case 0:
17901 default:
17902 e = new eRock((zfix)x,(zfix)y,id,clk);
17903 break;
17904 }
17905
17906 break;
17907 }
17908
17909 case eeTRAP:
17910 {
17911 switch(guysbuf[id&0xFFF].misc2)
17912 {
17913 case 1:
17914 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17915 break;
17916
17917 case 0:
17918 default:
17919 e = new eTrap((zfix)x,(zfix)y,id,clk);
17920 break;
17921 }
17922
17923 break;
17924 }
17925
17926 case eeDONGO:
17927 {
17928 switch(guysbuf[id&0xFFF].misc10)
17929 {
17930 case 1:
17931 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17932 break;
17933
17934 case 0:
17935 default:
17936 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17937 break;
17938 }
17939
17940 break;
17941 }
17942
17943 case eeDIG:
17944 {
17945
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
17946 {
17947 case 1:
17948 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17949 break;
17950
17951 4 case 0:
17952 default:
17953
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17954 4 break;
17955 }
17956
17957 4 break;
17958 }
17959
17960 case eePATRA:
17961 {
17962 switch(guysbuf[id&0xFFF].misc10)
17963 {
17964 case 1:
17965 if (get_qr(qr_HARDCODED_BS_PATRA))
17966 {
17967 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17968 break;
17969 }
17970 [[fallthrough]];
17971 case 0:
17972 default:
17973 e = new ePatra((zfix)x,(zfix)y,id,clk);
17974 break;
17975 }
17976
17977 break;
17978 }
17979
17980 case eeGUY:
17981 {
17982 switch(guysbuf[id&0xFFF].misc10)
17983 {
17984 case 1:
17985 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17986 break;
17987
17988 case 0:
17989 default:
17990 e = new eNPC((zfix)x,(zfix)y,id,clk);
17991 break;
17992 }
17993
17994 break;
17995 }
17996
17997 case eeNONE:
17998 if(guysbuf[id&0xFFF].misc10 ==1)
17999 {
18000 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18001 break;
18002 break;
18003 }
18004 [[fallthrough]];
18005 default:
18006
18007 return 0;
18008 }
18009
18010 893 ret++; // Made one enemy.
18011
18012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
18013 {
18014 e->z = (zfix)z;
18015 }
18016
18017
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 ((enemy*)e)->ceiling = (z && canfall(id));
18018 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
18019 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
18020 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
18021 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18022 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18023
18024
18025
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
18026 {
18027 return 0;
18028 }
18029
18030 // add segments of segmented enemies
18031 893 int32_t c=0;
18032
18033
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
18034 {
18035 case eeMOLD:
18036 {
18037 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18038 id &= 0xFFF;
18039
18040 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18041 {
18042 //christ this is messy -DD
18043 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18044
18045 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18046 {
18047 al_trace("Moldorm segment %d could not be created!\n",i+1);
18048
18049 for(int32_t j=0; j<i+1; j++)
18050 guys.del(guys.Count()-1);
18051
18052 return 0;
18053 }
18054
18055 if(i>0)
18056 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18057
18058 ret++;
18059 }
18060
18061 break;
18062 }
18063
18064 case eeLANM:
18065 {
18066 id &= 0xFFF;
18067 int32_t shft = guysbuf[id].misc2;
18068 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18069
18070 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18071 {
18072 al_trace("Lanmola segment 1 could not be created!\n");
18073 guys.del(guys.Count()-1);
18074 return 0;
18075 }
18076
18077 ret++;
18078
18079 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18080 {
18081 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18082 {
18083 al_trace("Lanmola segment %d could not be created!\n",i+1);
18084
18085 for(int32_t j=0; j<i+1; j++)
18086 guys.del(guys.Count()-1);
18087
18088 return 0;
18089 }
18090
18091 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18092 ret++;
18093 }
18094 }
18095 break;
18096
18097 case eeMANHAN:
18098 1 id &= 0xFFF;
18099
18100
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18101 {
18102
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18103 {
18104 al_trace("Manhandla head %d could not be created!\n",i+1);
18105
18106 for(int32_t j=0; j<i+1; j++)
18107 {
18108 guys.del(guys.Count()-1);
18109 }
18110
18111 return 0;
18112 }
18113
18114 4 ret++;
18115 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18116 4 }
18117
18118 1 break;
18119
18120 case eeGLEEOK:
18121 {
18122 id &= 0xFFF;
18123
18124 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18125 {
18126 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
18127 {
18128 al_trace("Gleeok head %d could not be created!\n",i+1);
18129
18130 for(int32_t j=0; j<i+1; j++)
18131 {
18132 guys.del(guys.Count()-1);
18133 }
18134
18135 return false;
18136 }
18137
18138 c-=guysbuf[id].misc4;
18139 ret++;
18140 }
18141 }
18142 break;
18143
18144
18145 case eePATRA:
18146 {
18147 id &= 0xFFF;
18148 int32_t outeyes = 0;
18149
18150 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18151 {
18152 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18153 {
18154 al_trace("Patra outer eye %d could not be created!\n",i+1);
18155
18156 for(int32_t j=0; j<i+1; j++)
18157 guys.del(guys.Count()-1);
18158
18159 return 0;
18160 }
18161 else
18162 outeyes++;
18163
18164 ret++;
18165 }
18166
18167 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18168 {
18169 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18170 {
18171 al_trace("Patra inner eye %d could not be created!\n",i+1);
18172
18173 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18174 guys.del(guys.Count()-1);
18175
18176 return 0;
18177 }
18178
18179 ret++;
18180 }
18181
18182 break;
18183 }
18184 }
18185
18186 893 return ret;
18187 893 }
18188
18189 // Returns number of enemies/segments created
18190 52936 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
18191 {
18192 //zprint2("addenemy id is: %d\n", (id&0xFFF));
18193 52936 int32_t realid = id&0xFFF;
18194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if( realid > MAXGUYS )
18195 {
18196 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
18197 return 0;
18198 }
18199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if(id <= 0) return 0;
18200
18201 52936 int32_t ret = 0;
18202 52936 sprite *e=NULL;
18203
18204
27/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26744 times.
✓ Branch 4 taken 1694 times.
✓ Branch 5 taken 2941 times.
✓ Branch 6 taken 1048 times.
✓ Branch 7 taken 1605 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 5764 times.
✓ Branch 10 taken 2135 times.
✓ Branch 11 taken 2257 times.
✓ Branch 12 taken 523 times.
✓ Branch 13 taken 76 times.
✓ Branch 14 taken 94 times.
✓ Branch 15 taken 58 times.
✓ Branch 16 taken 94 times.
✓ Branch 17 taken 55 times.
✓ Branch 18 taken 239 times.
✓ Branch 19 taken 10 times.
✓ Branch 20 taken 413 times.
✓ Branch 21 taken 374 times.
✓ Branch 22 taken 4900 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 256 times.
✓ Branch 25 taken 889 times.
✓ Branch 26 taken 141 times.
✓ Branch 27 taken 246 times.
✓ Branch 28 taken 56 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 90 times.
52936 switch(guysbuf[id&0xFFF].family)
18205 {
18206 //Fixme: possible enemy memory leak. (minor)
18207 case eeWALK:
18208
3/6
✓ Branch 0 taken 26744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26744 times.
✗ Branch 5 not taken.
26744 e = new eStalfos((zfix)x,(zfix)y,id,clk);
18209 26744 break;
18210
18211 case eeLEV:
18212
3/6
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1694 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1694 times.
✗ Branch 5 not taken.
1694 e = new eLeever((zfix)x,(zfix)y,id,clk);
18213 1694 break;
18214
18215 case eeTEK:
18216
3/6
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2941 times.
✗ Branch 5 not taken.
2941 e = new eTektite((zfix)x,(zfix)y,id,clk);
18217 2941 break;
18218
18219 case eePEAHAT:
18220
3/6
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
1048 e = new ePeahat((zfix)x,(zfix)y,id,clk);
18221 1048 break;
18222
18223 case eeZORA:
18224
3/6
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1605 times.
✗ Branch 5 not taken.
1605 e = new eZora((zfix)x,(zfix)y,id,clk);
18225 1605 break;
18226
18227 case eeGHINI:
18228
3/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
140 e = new eGhini((zfix)x,(zfix)y,id,clk);
18229 140 break;
18230
18231 case eeKEESE:
18232
3/6
✓ Branch 0 taken 5764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5764 times.
✗ Branch 5 not taken.
5764 e = new eKeese((zfix)x,(zfix)y,id,clk);
18233 5764 break;
18234
18235 case eeWIZZ:
18236
3/6
✓ Branch 0 taken 2135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2135 times.
✗ Branch 5 not taken.
2135 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
18237 2135 break;
18238
18239 case eePROJECTILE:
18240
3/6
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
2257 e = new eProjectile((zfix)x,(zfix)y,id,clk);
18241 2257 break;
18242
18243 case eeWALLM:
18244
3/6
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 523 times.
✗ Branch 5 not taken.
523 e = new eWallM((zfix)x,(zfix)y,id,clk);
18245 523 break;
18246
18247 case eeAQUA:
18248
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
18249 76 break;
18250
18251 case eeMOLD:
18252
6/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 94 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18253 94 break;
18254
18255 case eeMANHAN:
18256
3/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
58 e = new eManhandla((zfix)x,(zfix)y,id,clk);
18257 58 break;
18258
18259 case eeGLEEOK:
18260
7/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 79 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18261 94 break;
18262
18263 case eeGHOMA:
18264
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 e = new eGohma((zfix)x,(zfix)y,id,clk);
18265 55 break;
18266
18267 case eeLANM:
18268
6/12
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239 times.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 239 times.
✓ Branch 10 taken 239 times.
✗ Branch 11 not taken.
239 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
18269 239 break;
18270
18271 case eeGANON:
18272
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 e = new eGanon((zfix)x,(zfix)y,id,clk);
18273 10 break;
18274
18275 case eeFAIRY:
18276
3/6
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
413 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
18277 413 break;
18278
18279 case eeFIRE:
18280
3/6
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
374 e = new eFire((zfix)x,(zfix)y,id,clk);
18281 374 break;
18282
18283 case eeOTHER:
18284
3/6
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4900 times.
✗ Branch 5 not taken.
4900 e = new eOther((zfix)x,(zfix)y,id,clk);
18285 4900 break;
18286
18287
18288 case eeSCRIPT01:
18289 case eeSCRIPT02:
18290 case eeSCRIPT03:
18291 case eeSCRIPT04:
18292 case eeSCRIPT05:
18293 case eeSCRIPT06:
18294 case eeSCRIPT07:
18295 case eeSCRIPT08:
18296 case eeSCRIPT09:
18297 case eeSCRIPT10:
18298 case eeSCRIPT11:
18299 case eeSCRIPT12:
18300 case eeSCRIPT13:
18301 case eeSCRIPT14:
18302 case eeSCRIPT15:
18303 case eeSCRIPT16:
18304 case eeSCRIPT17:
18305 case eeSCRIPT18:
18306 case eeSCRIPT19:
18307 case eeSCRIPT20:
18308 {
18309 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18310 {
18311 e = new eScript((zfix)x,(zfix)y,id,clk);
18312 break;
18313 }
18314 else return 0;
18315 }
18316
18317 case eeFFRIENDLY01:
18318 case eeFFRIENDLY02:
18319 case eeFFRIENDLY03:
18320 case eeFFRIENDLY04:
18321 case eeFFRIENDLY05:
18322 case eeFFRIENDLY06:
18323 case eeFFRIENDLY07:
18324 case eeFFRIENDLY08:
18325 case eeFFRIENDLY09:
18326 case eeFFRIENDLY10:
18327 {
18328 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18329 {
18330 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
18331 }
18332 else return 0;
18333
18334 }
18335
18336 case eeSPINTILE:
18337
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
18338 94 break;
18339
18340 // and these enemies use the misc10/misc2 value
18341 case eeROCK:
18342 {
18343
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 226 times.
256 switch(guysbuf[id&0xFFF].misc10)
18344 {
18345 case 1:
18346
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
18347 30 break;
18348
18349 226 case 0:
18350 default:
18351
3/6
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
226 e = new eRock((zfix)x,(zfix)y,id,clk);
18352 226 break;
18353 }
18354
18355 256 break;
18356 }
18357
18358 case eeTRAP:
18359 {
18360
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 742 times.
889 switch(guysbuf[id&0xFFF].misc2)
18361 {
18362 case 1:
18363
3/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
147 e = new eTrap2((zfix)x,(zfix)y,id,clk);
18364 147 break;
18365
18366 742 case 0:
18367 default:
18368
3/6
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 742 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 742 times.
✗ Branch 5 not taken.
742 e = new eTrap((zfix)x,(zfix)y,id,clk);
18369 742 break;
18370 }
18371
18372 889 break;
18373 }
18374
18375 case eeDONGO:
18376 {
18377
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 139 times.
141 switch(guysbuf[id&0xFFF].misc10)
18378 {
18379 case 1:
18380
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
18381 2 break;
18382
18383 139 case 0:
18384 default:
18385
3/6
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
139 e = new eDodongo((zfix)x,(zfix)y,id,clk);
18386 139 break;
18387 }
18388
18389 141 break;
18390 }
18391
18392 case eeDIG:
18393 {
18394
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 48 times.
246 switch(guysbuf[id&0xFFF].misc10)
18395 {
18396 case 1:
18397
3/6
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
198 e = new eLilDig((zfix)x,(zfix)y,id,clk);
18398 198 break;
18399
18400 48 case 0:
18401 default:
18402
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eBigDig((zfix)x,(zfix)y,id,clk);
18403 48 break;
18404 }
18405
18406 246 break;
18407 }
18408
18409 case eePATRA:
18410 {
18411
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 3 times.
56 switch(guysbuf[id&0xFFF].misc10)
18412 {
18413 case 1:
18414
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_qr(qr_HARDCODED_BS_PATRA))
18415 {
18416
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
18417 3 break;
18418 }
18419 [[fallthrough]];
18420 53 case 0:
18421 default:
18422
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new ePatra((zfix)x,(zfix)y,id,clk);
18423 53 break;
18424 }
18425
18426 56 break;
18427 }
18428
18429 case eeGUY:
18430 {
18431 switch(guysbuf[id&0xFFF].misc10)
18432 {
18433 case 1:
18434 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18435 break;
18436
18437 case 0:
18438 default:
18439 e = new eNPC((zfix)x,(zfix)y,id,clk);
18440 break;
18441 }
18442
18443 break;
18444 }
18445
18446 case eeNONE:
18447
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(guysbuf[id&0xFFF].misc10 ==1)
18448 {
18449
3/6
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
90 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18450 90 break;
18451 break;
18452 }
18453 [[fallthrough]];
18454 default:
18455
18456 return 0;
18457 }
18458
18459 52936 ret++; // Made one enemy.
18460
18461
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 52853 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
52936 if(z && canfall(id))
18462 {
18463 59 e->z = (zfix)z;
18464 59 }
18465
18466
2/2
✓ Branch 0 taken 52853 times.
✓ Branch 1 taken 83 times.
52936 ((enemy*)e)->ceiling = (z && canfall(id));
18467
18468
1/2
✓ Branch 0 taken 52936 times.
✗ Branch 1 not taken.
52936 if(!guys.add(e))
18469 {
18470 return 0;
18471 }
18472
18473 // add segments of segmented enemies
18474 52936 int32_t c=0;
18475
18476
6/6
✓ Branch 0 taken 52395 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 56 times.
52936 switch(guysbuf[id&0xFFF].family)
18477 {
18478 case eeMOLD:
18479 {
18480 94 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18481 94 id &= 0xFFF;
18482
18483
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 624 times.
✓ Branch 2 taken 624 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 624 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 94 times.
624 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18484 {
18485 //christ this is messy -DD
18486 530 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18487
18488
4/8
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 530 times.
✗ Branch 7 not taken.
530 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18489 {
18490 al_trace("Moldorm segment %d could not be created!\n",i+1);
18491
18492 for(int32_t j=0; j<i+1; j++)
18493 guys.del(guys.Count()-1);
18494
18495 return 0;
18496 }
18497
18498
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 436 times.
530 if(i>0)
18499 436 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18500
18501 530 ret++;
18502 530 }
18503
18504 94 break;
18505 }
18506
18507 case eeLANM:
18508 {
18509 239 id &= 0xFFF;
18510 239 int32_t shft = guysbuf[id].misc2;
18511 239 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18512
18513
4/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
239 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18514 {
18515 al_trace("Lanmola segment 1 could not be created!\n");
18516 guys.del(guys.Count()-1);
18517 return 0;
18518 }
18519
18520 239 ret++;
18521
18522
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1250 times.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1250 times.
✓ Branch 6 taken 1011 times.
✓ Branch 7 taken 239 times.
1250 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18523 {
18524
4/8
✓ Branch 0 taken 1011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
1011 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18525 {
18526 al_trace("Lanmola segment %d could not be created!\n",i+1);
18527
18528 for(int32_t j=0; j<i+1; j++)
18529 guys.del(guys.Count()-1);
18530
18531 return 0;
18532 }
18533
18534 1011 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18535 1011 ret++;
18536 1011 }
18537 }
18538 239 break;
18539
18540 case eeMANHAN:
18541 58 id &= 0xFFF;
18542
18543
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 58 times.
322 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18544 {
18545
4/8
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 264 times.
✗ Branch 7 not taken.
264 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18546 {
18547 al_trace("Manhandla head %d could not be created!\n",i+1);
18548
18549 for(int32_t j=0; j<i+1; j++)
18550 {
18551 guys.del(guys.Count()-1);
18552 }
18553
18554 return 0;
18555 }
18556
18557 264 ret++;
18558 264 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18559 264 }
18560
18561 58 break;
18562
18563 case eeGLEEOK:
18564 {
18565 94 id &= 0xFFF;
18566 94 eGleeok* parent = (eGleeok*)e;
18567
18568
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 332 times.
✓ Branch 6 taken 268 times.
✓ Branch 7 taken 94 times.
362 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18569 {
18570
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18571
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!guys.add(head))
18572 {
18573 al_trace("Gleeok head %d could not be created!\n",i+1);
18574
18575 for(int32_t j=0; j<i+1; j++)
18576 {
18577 guys.del(guys.Count()-1);
18578 }
18579
18580 return false;
18581 }
18582
18583 268 head->necktile=parent->necktile;
18584 268 head->dummy_int[1]=parent->necktile;
18585
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 73 times.
268 if(get_qr(qr_NEWENEMYTILES))
18586 {
18587 195 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18588 195 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18589 195 }
18590 else
18591 {
18592 73 head->dummy_int[2]=parent->necktile+1; //connected head tile
18593 73 head->dummy_int[3]=parent->necktile+2; //flying head tile
18594 }
18595 268 head->tile = head->dummy_int[2];
18596
18597 268 c-=guysbuf[id].misc4;
18598 268 ret++;
18599 268 }
18600 }
18601 94 break;
18602
18603
18604 case eePATRA:
18605 {
18606 56 id &= 0xFFF;
18607 56 int32_t outeyes = 0;
18608
18609
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 498 times.
✓ Branch 2 taken 442 times.
✓ Branch 3 taken 56 times.
498 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18610 {
18611
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 424 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 424 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 424 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 424 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
442 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18612 {
18613 al_trace("Patra outer eye %d could not be created!\n",i+1);
18614
18615 for(int32_t j=0; j<i+1; j++)
18616 guys.del(guys.Count()-1);
18617
18618 return 0;
18619 }
18620 else
18621 442 outeyes++;
18622
18623 442 ret++;
18624 442 }
18625
18626
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 56 times.
144 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18627 {
18628
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18629 {
18630 al_trace("Patra inner eye %d could not be created!\n",i+1);
18631
18632 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18633 guys.del(guys.Count()-1);
18634
18635 return 0;
18636 }
18637
18638 88 ret++;
18639 88 }
18640
18641 56 break;
18642 }
18643 }
18644
18645 52936 return ret;
18646 52936 }
18647
18648 1251618 bool isjumper(int32_t id)
18649 {
18650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251618 times.
1251618 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18651 {
18652 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
18653 return false;
18654 }
18655
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1151282 times.
✓ Branch 2 taken 100332 times.
1251618 switch(guysbuf[id&0xFFF].family)
18656 {
18657 case eeROCK:
18658 case eeTEK:
18659 4 return true;
18660
18661 case eeWALK:
18662
3/4
✓ Branch 0 taken 100332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 88067 times.
100332 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
18663 88067 }
18664
18665 1239349 return false;
18666 1251618 }
18667
18668
18669 115481 bool isfixedtogrid(int32_t id)
18670 {
18671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115481 times.
115481 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18672 {
18673 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
18674 return false;
18675 }
18676
1/2
✓ Branch 0 taken 115481 times.
✗ Branch 1 not taken.
115481 switch(guysbuf[id&0xFFF].family)
18677 {
18678 case eeWALK:
18679 case eeLEV:
18680 case eeZORA:
18681 case eeDONGO:
18682 case eeGANON:
18683 case eeROCK:
18684 case eeGLEEOK:
18685 case eeAQUA:
18686 case eeLANM:
18687 return true;
18688 }
18689
18690 115481 return false;
18691 115481 }
18692
18693 // Can't fall, can have Z value.
18694 30363108 bool isflier(int32_t id)
18695 {
18696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30363108 times.
30363108 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18697 {
18698 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
18699 return false;
18700 }
18701
2/2
✓ Branch 0 taken 27055941 times.
✓ Branch 1 taken 3307167 times.
30363108 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18702 {
18703 case eePEAHAT:
18704 case eeKEESE:
18705 case eePATRA:
18706 case eeFAIRY:
18707 case eeGHINI:
18708
18709 // Could theoretically have their Z set by a script
18710 case eeFIRE:
18711 3307167 return true;
18712 break;
18713 }
18714
18715 27055941 return false;
18716 30363108 }
18717
18718 // Can't have Z position
18719 2341162 bool never_in_air(int32_t id)
18720 {
18721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2341162 times.
2341162 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18722 {
18723 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
18724 return false;
18725 }
18726
2/2
✓ Branch 0 taken 2331614 times.
✓ Branch 1 taken 9548 times.
2341162 switch(guysbuf[id&0xFFF].family)
18727 {
18728 case eeMANHAN:
18729 case eeMOLD:
18730 case eeLANM:
18731 case eeGLEEOK:
18732 case eeZORA:
18733 case eeLEV:
18734 case eeAQUA:
18735 case eeROCK:
18736 case eeGANON:
18737 case eeTRAP:
18738 case eePROJECTILE:
18739 case eeSPINTILE:
18740 9548 return true;
18741 }
18742
18743 2331614 return false;
18744 2341162 }
18745
18746 1370668 bool canfall(int32_t id)
18747 {
18748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1370668 times.
1370668 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18749 {
18750 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
18751 return false;
18752 }
18753
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1370642 times.
✓ Branch 2 taken 26 times.
1370668 switch(guysbuf[id&0xFFF].family)
18754 {
18755 case eeGUY:
18756 {
18757
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(id < eOCTO1S)
18758 26 return false;
18759
18760 switch(guysbuf[id&0xFFF].misc10)
18761 {
18762 case 1:
18763 case 2:
18764 return true;
18765
18766 case 0:
18767 case 3:
18768 default:
18769 return false;
18770 }
18771
18772 case eeGHOMA:
18773 case eeDIG:
18774 return false;
18775 }
18776 }
18777
18778
18779
4/4
✓ Branch 0 taken 1362208 times.
✓ Branch 1 taken 8434 times.
✓ Branch 2 taken 110590 times.
✓ Branch 3 taken 1251618 times.
1370642 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18780 1370668 }
18781
18782 31454090 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18783 {
18784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31454090 times.
31454090 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18785 {
18786 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
18787 return false;
18788 }
18789 //Z_scripterrlog("canfall family is %d:\n", family);
18790 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
18791 //if ( family == eeFIRE && id >= eSTART )
18792 //{
18793 // Z_scripterrlog("eeFire\n");
18794 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
18795 //}
18796
18797 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18798
18799
3/3
✓ Branch 0 taken 195032 times.
✓ Branch 1 taken 30218229 times.
✓ Branch 2 taken 1040829 times.
31454090 switch(guysbuf[id&0xFFF].family)
18800 {
18801 case eeGUY:
18802 {
18803
1/2
✓ Branch 0 taken 1040829 times.
✗ Branch 1 not taken.
1040829 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18804 1040829 return false;
18805
18806 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
18807 {
18808 case 1:
18809 case 2:
18810 return true;
18811
18812 case 0:
18813 case 3:
18814 default:
18815 return false;
18816 }
18817
18818 case eeGHOMA:
18819 case eeDIG:
18820 195032 return false;
18821 }
18822 }
18823
18824
2/2
✓ Branch 0 taken 21662519 times.
✓ Branch 1 taken 8555710 times.
30218229 if(!checkgrav) return true;
18825 21662519 return (moveflags & FLAG_OBEYS_GRAV);
18826
18827 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18828 // {
18829 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
18830 // else return false;
18831 // }
18832 // else
18833 // {
18834 // return (moveflags & FLAG_OBEYS_GRAV);
18835 // }
18836 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18837 31454090 }
18838
18839 758 void addfires()
18840 {
18841
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 336 times.
758 if(!get_qr(qr_NOGUYFIRES))
18842 {
18843 336 int32_t bs = get_qr(qr_BSZELDA);
18844 336 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18845 336 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18846 336 }
18847 758 }
18848
18849 16278 void loadguys()
18850 {
18851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16278 times.
16278 if(loaded_guys)
18852 return;
18853
18854 16278 loaded_guys=true;
18855
18856 16278 byte Guy=0;
18857 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18858 // Else use mITEM and ipONETIME
18859 16278 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18860 16278 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18861
18862 16278 repaircharge=0;
18863 16278 adjustmagic=false;
18864 16278 learnslash=false;
18865
18866
2/2
✓ Branch 0 taken 48834 times.
✓ Branch 1 taken 16278 times.
65112 for(int32_t i=0; i<3; i++)
18867 {
18868 48834 prices[i]=0;
18869 48834 }
18870
18871 16278 hasitem=0;
18872
18873 16278 mapscr* guyscr = tmpscr;
18874
4/4
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 15599 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 339 times.
16278 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18875 {
18876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(DMaps[currdmap].flags&dmfCAVES)
18877 {
18878 339 Guy=tmpscr[1].guy;
18879 339 guyscr = tmpscr+1;
18880 339 }
18881 339 }
18882 else
18883 {
18884 15939 Guy=tmpscr->guy;
18885
18886
4/4
✓ Branch 0 taken 15599 times.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 9437 times.
✓ Branch 3 taken 6162 times.
15939 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18887 6162 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18888 }
18889
18890 16278 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18891 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18892
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 13420 times.
✓ Branch 2 taken 2081 times.
✓ Branch 3 taken 777 times.
16278 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18893 {
18894
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 768 times.
777 if(tmpscr->room==rZELDA)
18895 {
18896 9 addguy(120,72,Guy,-15,true,guyscr);
18897 9 guys.spr(0)->hxofs=1000;
18898 9 addenemy(128,96,eFIRE,-15);
18899 9 addenemy(112,96,eFIRE,-15);
18900 9 addenemy(96,120,eFIRE,-15);
18901 9 addenemy(144,120,eFIRE,-15);
18902 9 return;
18903 }
18904
18905
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
1536 bool ffire = oldguy
18906
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 10 times.
768 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18907 : (guyscr->roomflags&RFL_GUYFIRES);
18908
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 758 times.
768 if(ffire)
18909 758 addfires();
18910
18911
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 335 times.
768 if(currscr>=128)
18912
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
347 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18913 12 Guy=0;
18914
18915
4/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 647 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
768 switch(tmpscr->room)
18916 {
18917 case rSP_ITEM:
18918 case rGRUMBLE:
18919 case rBOMBS:
18920 case rARROWS:
18921 case rSWINDLE:
18922 case rMUPGRADE:
18923 case rLEARNSLASH:
18924 case rTAKEONE:
18925
8/8
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
97 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18926 28 Guy=0;
18927
18928 117 break;
18929
18930 case rREPAIR:
18931 if (get_qr(qr_OLD_DOORREPAIR)) break;
18932 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18933 Guy=0;
18934
18935 break;
18936 case rRP_HC:
18937 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18938 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18939 Guy=0;
18940
18941 break;
18942 case rMONEY:
18943
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18944 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18945 Guy=0;
18946
18947 break;
18948
18949 case rTRIFORCE:
18950 {
18951 23 int32_t tc = TriforceCount();
18952
18953
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 12 times.
23 if(get_qr(qr_4TRI))
18954 {
18955
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18956 10 Guy=0;
18957 9 }
18958 else
18959 {
18960
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18961 12 Guy=0;
18962 }
18963 }
18964 21 break;
18965 }
18966
18967
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 708 times.
766 if(Guy)
18968 {
18969
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 698 times.
708 if(ffire)
18970 698 blockpath=true;
18971
18972
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 385 times.
708 if(currscr<128)
18973 385 sfx(WAV_SCALE);
18974
18975
4/4
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 382 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 323 times.
708 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18976 708 Hero.Freeze();
18977 708 }
18978 766 }
18979
3/6
✓ Branch 0 taken 15501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 15450 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15501 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18980 {
18981 51 sfx(WAV_SCALE);
18982 51 addguy(120,62,Guy,-14,false,guyscr);
18983 51 }
18984
18985 16267 loaditem();
18986
18987 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18988 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18989
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16257 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
16267 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18990 {
18991 //setmapflag();
18992
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 8 times.
88 for(int32_t i=0; i<10; i++)
18993 80 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18994 8 }
18995 16276 }
18996
18997 16283 void loaditem()
18998 {
18999 16283 byte Item = 0;
19000
19001
2/2
✓ Branch 0 taken 15604 times.
✓ Branch 1 taken 679 times.
16283 if(currscr<128)
19002 {
19003 15604 Item=tmpscr->item;
19004
19005
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 14806 times.
✓ Branch 2 taken 14230 times.
✓ Branch 3 taken 1374 times.
15604 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
19006 {
19007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1374 times.
1374 if(tmpscr->flags8&fSECRETITEM)
19008 hasitem=8;
19009
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 745 times.
1374 else if(tmpscr->flags&fITEM)
19010 629 hasitem=1;
19011
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 711 times.
745 else if(tmpscr->enemyflags&efCARRYITEM)
19012 34 hasitem=4; // Will be set to 2 by roaming_item
19013 else
19014
2/4
✓ Branch 0 taken 711 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 711 times.
✗ Branch 3 not taken.
1422 items.add(new item((zfix)tmpscr->itemx,
19015
6/12
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 711 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 711 times.
✗ Branch 11 not taken.
711 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19016
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 708 times.
✗ Branch 9 not taken.
711 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19017
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 649 times.
711 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
19018 711 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19019 1374 }
19020 15604 }
19021
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 else if(!(DMaps[currdmap].flags&dmfCAVES))
19022 {
19023
4/6
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
341 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
19024
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 109 times.
340 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
19025 {
19026 110 Item=tmpscr[1].catchall;
19027
19028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Item)
19029
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
220 items.add(new item((zfix)tmpscr->itemx,
19030
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
110 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19031
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
110 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19032 110 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19033 110 }
19034 340 }
19035 16283 }
19036
19037 539 void never_return(int32_t index)
19038 {
19039
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 130 times.
539 if(!get_qr(qr_KILLALL))
19040 130 goto doit;
19041
19042
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 201 times.
1541 for(int32_t i=0; i<guys.Count(); i++)
19043
4/4
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 306 times.
1340 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
19044 {
19045 208 goto dontdoit;
19046 201 }
19047
19048 doit:
19049 331 setmapflag(mNEVERRET);
19050 dontdoit:
19051 539 return;
19052 }
19053
19054 36942 bool slowguy(int32_t id)
19055 {
19056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36942 times.
36942 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19057 {
19058 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
19059 return false;
19060 }
19061 //return (guysbuf[id].step<100);
19062
2/2
✓ Branch 0 taken 31379 times.
✓ Branch 1 taken 5563 times.
36942 switch(id)
19063 {
19064 case eOCTO1S:
19065 case eOCTO2S:
19066 case eOCTO1F:
19067 case eOCTO2F:
19068 case eLEV1:
19069 case eLEV2:
19070 case eROCK:
19071 case eBOULDER:
19072 5563 return true;
19073 }
19074
19075 31379 return false;
19076 36942 }
19077
19078 41699 bool ok2add(int32_t id)
19079 {
19080
2/4
✓ Branch 0 taken 41699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41699 times.
41699 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
19081 {
19082 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
19083 return false;
19084 }
19085
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 41291 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 218 times.
41699 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
19086 218 return false;
19087
19088
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 92 times.
41481 switch(guysbuf[id].family)
19089 {
19090 // I added a special case for shooters because having traps on the same screen
19091 // was preventing them from spawning due to TMPNORET. This means they will
19092 // never stay dead, though, so it may not be the best solution. - Saf
19093 case eePROJECTILE:
19094 63 return true;
19095
19096
19097 case eeDIG:
19098 {
19099
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 47 times.
92 switch(guysbuf[id].misc10)
19100 {
19101 case 1:
19102
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_qr(qr_NOTMPNORET))
19103 13 return !getmapflag(mTMPNORET);
19104
19105 32 return true;
19106
19107 47 case 0:
19108 default:
19109 47 return true;
19110 }
19111 }
19112 case eeGANON:
19113 case eeTRAP:
19114 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
19115 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
19116 [[fallthrough]];
19117 default:
19118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
41326 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
19119 41326 break;
19120 }
19121
19122
2/2
✓ Branch 0 taken 14322 times.
✓ Branch 1 taken 27004 times.
41326 if(!get_qr(qr_NOTMPNORET))
19123 27004 return !getmapflag(mTMPNORET);
19124
19125 14322 return true;
19126 41699 }
19127
19128 402634 void activate_fireball_statue(int32_t pos)
19129 {
19130
3/4
✓ Branch 0 taken 113289 times.
✓ Branch 1 taken 289345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113289 times.
402634 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
19131 {
19132 289345 return;
19133 }
19134
19135 113289 int32_t cx=-1000, cy=-1000;
19136 113289 int32_t x = (pos&15)<<4;
19137 113289 int32_t y = pos&0xF0;
19138
19139 113289 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19140
19141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113289 times.
113289 if(!isfixedtogrid(statueID))
19142 {
19143
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 112292 times.
113289 if(ctype==cL_STATUE)
19144 {
19145 997 cx=x+4;
19146 997 cy=y+7;
19147 997 }
19148
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 111276 times.
112292 else if(ctype==cR_STATUE)
19149 {
19150 1016 cx=x-8;
19151 1016 cy=y-1;
19152 1016 }
19153
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 179 times.
111276 else if(ctype==cC_STATUE)
19154 {
19155 179 cx=x;
19156 179 cy=y;
19157 179 }
19158 113289 }
19159 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
19160 {
19161 cx=x;
19162 cy=y;
19163 }
19164
19165
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 2192 times.
113289 if(cx!=-1000) // No point creating it if this is false
19166 {
19167
2/2
✓ Branch 0 taken 6281 times.
✓ Branch 1 taken 2192 times.
8473 for(int32_t j=0; j<guys.Count(); j++)
19168 {
19169
3/4
✓ Branch 0 taken 1171 times.
✓ Branch 1 taken 5110 times.
✓ Branch 2 taken 1171 times.
✗ Branch 3 not taken.
6281 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
19170 {
19171 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
19172 return; // No point deleting it. A script might be toying with it in some way.
19173 else
19174 guys.del(j);
19175 }
19176 6281 }
19177
19178 2192 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
19179 2192 }
19180 402634 }
19181
19182 16138 void activate_fireball_statues()
19183 {
19184
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 15520 times.
16138 if(!(tmpscr->enemyflags&efFIREBALLS))
19185 {
19186 15520 return;
19187 }
19188
19189
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 108768 times.
109386 for(int32_t i=0; i<176; i++)
19190 {
19191 108768 activate_fireball_statue(i);
19192 108768 }
19193 16138 }
19194
19195 16138 void load_default_enemies()
19196 {
19197 16138 wallm_load_clk=frame-80;
19198
19199
2/2
✓ Branch 0 taken 15106 times.
✓ Branch 1 taken 1032 times.
16138 if(tmpscr->enemyflags&efZORA)
19200 {
19201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(zoraID>=0)
19202 1032 addenemy(-16, -16, zoraID, 0);
19203 1032 }
19204
19205
2/2
✓ Branch 0 taken 16035 times.
✓ Branch 1 taken 103 times.
16138 if(tmpscr->enemyflags&efTRAP4)
19206 {
19207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(cornerTrapID>=0)
19208 {
19209 103 addenemy(32, 32, cornerTrapID, -14);
19210 103 addenemy(208, 32, cornerTrapID, -14);
19211 103 addenemy(32, 128, cornerTrapID, -14);
19212 103 addenemy(208, 128, cornerTrapID, -14);
19213 103 }
19214 103 }
19215
19216
2/2
✓ Branch 0 taken 177518 times.
✓ Branch 1 taken 16138 times.
193656 for(int32_t y=0; y<176; y+=16)
19217 {
19218
2/2
✓ Branch 0 taken 2840288 times.
✓ Branch 1 taken 177518 times.
3017806 for(int32_t x=0; x<256; x+=16)
19219 {
19220 2840288 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19221 2840288 int32_t cflag = MAPFLAG(x, y);
19222 2840288 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19223
19224
4/6
✓ Branch 0 taken 2840288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840217 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840217 times.
2840288 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
19225 {
19226
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 61 times.
71 if(trapLOSHorizontalID>=0)
19227 61 addenemy(x, y, trapLOSHorizontalID, -14);
19228 71 }
19229
4/6
✓ Branch 0 taken 2840217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840181 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840181 times.
2840217 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
19230 {
19231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(trapLOSVerticalID>=0)
19232 36 addenemy(x, y, trapLOSVerticalID, -14);
19233 36 }
19234
4/6
✓ Branch 0 taken 2840181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840030 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840030 times.
2840181 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
19235 {
19236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(trapLOS4WayID>=0)
19237 {
19238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(addenemy(x, y, trapLOS4WayID, -14))
19239 151 guys.spr(guys.Count()-1)->dummy_int[1]=2;
19240 151 }
19241 151 }
19242
19243
4/6
✓ Branch 0 taken 2840030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839963 times.
✓ Branch 3 taken 67 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839963 times.
2840030 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
19244 {
19245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(trapConstantHorizontalID>=0)
19246 67 addenemy(x, y, trapConstantHorizontalID, -14);
19247 67 }
19248
4/6
✓ Branch 0 taken 2839963 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839883 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839883 times.
2839963 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
19249 {
19250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(trapConstantVerticalID>=0)
19251 80 addenemy(x, y, trapConstantVerticalID, -14);
19252 80 }
19253
19254
1/2
✓ Branch 0 taken 2840288 times.
✗ Branch 1 not taken.
2840288 if(ctype==cSPINTILE1)
19255 {
19256 // Awaken spinning tile
19257 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
19258 }
19259 2840288 }
19260 177518 }
19261
19262
2/2
✓ Branch 0 taken 16095 times.
✓ Branch 1 taken 43 times.
16138 if(tmpscr->enemyflags&efTRAP2)
19263 {
19264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(centerTrapID>=-1)
19265 {
19266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(64, 80, centerTrapID, -14))
19267 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19268
19269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(176, 80, centerTrapID, -14))
19270 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19271 43 }
19272 43 }
19273
19274
2/2
✓ Branch 0 taken 16071 times.
✓ Branch 1 taken 67 times.
16138 if(tmpscr->enemyflags&efROCKS)
19275 {
19276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(rockID>=0)
19277 {
19278 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19279 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19280 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19281 67 }
19282 67 }
19283
19284 16138 activate_fireball_statues();
19285 16138 }
19286
19287 20302703 void update_slope_combopos(int32_t lyr, int32_t pos)
19288 {
19289
2/4
✓ Branch 0 taken 20302703 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20302703 times.
20302703 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
19290 20302703 mapscr* s = FFCore.tempScreens[lyr];
19291 20302703 newcombo const& cmb = combobuf[s->data[pos]];
19292
19293 20302703 auto id = (176*lyr)+pos;
19294 20302703 auto it = slopes.find(id);
19295
19296 20302703 bool wasSlope = it!=slopes.end();
19297 20302703 bool isSlope = cmb.type == cSLOPE;
19298
19299
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 20302610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
20302703 if(isSlope && !wasSlope)
19300 {
19301 93 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
19302 93 }
19303
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20302610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20302610 else if(wasSlope && !isSlope)
19304 {
19305 slopes.erase(it);
19306 }
19307 20302703 }
19308 16293 void update_slope_comboposes()
19309 {
19310
2/2
✓ Branch 0 taken 114051 times.
✓ Branch 1 taken 16293 times.
130344 for(auto lyr = 0; lyr < 7; ++lyr)
19311 {
19312
2/2
✓ Branch 0 taken 20072976 times.
✓ Branch 1 taken 114051 times.
20187027 for(auto pos = 0; pos < 176; ++pos)
19313 20072976 update_slope_combopos(lyr,pos);
19314 114051 }
19315 16293 }
19316
19317 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
19318 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
19319 293866 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
19320 {
19321 293866 delete_fireball_shooter(s, pos);
19322 293866 }
19323
19324 //Placeholder in case we need it.
19325 void screen_ffc_modify_preroutine(word index)
19326 {
19327 return;
19328 }
19329
19330 // Everything that must be done after we change a screen's combo to another combo. -L
19331 293866 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
19332 {
19333 293866 s->valid |= mVALID;
19334 293866 activate_fireball_statue(pos);
19335
19336
2/2
✓ Branch 0 taken 293772 times.
✓ Branch 1 taken 94 times.
293866 if(combobuf[s->data[pos]].type==cSPINTILE1)
19337 {
19338 // Awaken spinning tile
19339 94 awaken_spinning_tile(s,pos);
19340 94 }
19341 293866 int32_t lyr = -1;
19342
2/2
✓ Branch 0 taken 89735 times.
✓ Branch 1 taken 204131 times.
293866 if(s == tmpscr) lyr = 0;
19343
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 479085 times.
543224 else for(size_t q = 0; q < 6; ++q)
19344 {
19345
2/2
✓ Branch 0 taken 25596 times.
✓ Branch 1 taken 453489 times.
479085 if(s == tmpscr2+q)
19346 {
19347 25596 lyr = q+1;
19348 25596 break;
19349 }
19350 453489 }
19351
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 229727 times.
293866 if(lyr > -1)
19352 229727 update_slope_combopos(lyr,pos);
19353 293866 }
19354
19355 4358385 void screen_ffc_modify_postroutine(word index)
19356 {
19357 4358385 ffcdata& ff = tmpscr->ffcs[index];
19358 4358385 newcombo const& cmb = combobuf[ff.data];
19359
19360 4358385 auto id = (176*7)+int32_t(index);
19361 4358385 auto it = slopes.find(id);
19362
19363 4358385 bool wasSlope = it!=slopes.end();
19364
1/2
✓ Branch 0 taken 4358385 times.
✗ Branch 1 not taken.
4358385 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
19365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358385 if(isSlope && !wasSlope)
19366 {
19367 slopes.try_emplace(id, nullptr, &ff, id);
19368 }
19369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358385 else if(wasSlope && !isSlope)
19370 {
19371 slopes.erase(it);
19372 }
19373
19374 4358385 tmpscr->ffcCountMarkDirty();
19375 4358385 }
19376
19377 4320 void screen_combo_modify_pre(int32_t cid)
19378 {
19379
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19380 {
19381 30240 mapscr* t = FFCore.tempScreens[lyr];
19382
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19383 {
19384
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19385 {
19386 4395 screen_combo_modify_preroutine(t,i);
19387 4395 }
19388 5322240 }
19389 30240 }
19390 4320 }
19391 4320 void screen_combo_modify_post(int32_t cid)
19392 {
19393
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19394 {
19395 30240 mapscr* t = FFCore.tempScreens[lyr];
19396
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19397 {
19398
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19399 {
19400 4395 screen_combo_modify_postroutine(t,i);
19401 4395 }
19402 5322240 }
19403 30240 }
19404
2/2
✓ Branch 0 taken 552960 times.
✓ Branch 1 taken 4320 times.
557280 for(word ind = 0; ind < MAXFFCS; ++ind)
19405 {
19406
1/2
✓ Branch 0 taken 552960 times.
✗ Branch 1 not taken.
552960 if(tmpscr->ffcs[ind].data == cid)
19407 screen_ffc_modify_postroutine(ind);
19408 552960 }
19409 4320 }
19410
19411 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
19412 {
19413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
19414 94 }
19415
19416
19417 // It stands for next_side_pos
19418 9987 void nsp(bool random)
19419 // moves sle_x and sle_y to the next position
19420 {
19421
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6726 times.
9987 if(random)
19422 {
19423
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
19424 {
19425 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
19426 1634 sle_y = (zc_oldrand()%10)*16;
19427 1634 }
19428 else
19429 {
19430 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
19431 1627 sle_x = (zc_oldrand()%15)*16;
19432 }
19433
19434 3261 return;
19435 }
19436
19437
2/2
✓ Branch 0 taken 5084 times.
✓ Branch 1 taken 1642 times.
6726 if(sle_x==0)
19438 {
19439
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 146 times.
1642 if(sle_y<160)
19440 1496 sle_y+=16;
19441 else
19442 146 sle_x+=16;
19443 1642 }
19444
2/2
✓ Branch 0 taken 2122 times.
✓ Branch 1 taken 2962 times.
5084 else if(sle_y==160)
19445 {
19446
2/2
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 137 times.
2122 if(sle_x<240)
19447 1985 sle_x+=16;
19448 else
19449 137 sle_y-=16;
19450 2122 }
19451
2/2
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 1674 times.
2962 else if(sle_x==240)
19452 {
19453
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 123 times.
1288 if(sle_y>0)
19454 1165 sle_y-=16;
19455 else
19456 123 sle_x-=16;
19457 1288 }
19458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
1674 else if(sle_y==0)
19459 {
19460
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if(sle_x>0)
19461 1674 sle_x-=16;
19462 else
19463 sle_y+=16;
19464 1674 }
19465 9987 }
19466
19467 1932 int32_t next_side_pos(bool random)
19468 // moves sle_x and sle_y to the next available position
19469 // returns the direction the enemy should face
19470 {
19471 bool blocked;
19472 1932 int32_t c=0;
19473
19474 1932 do
19475 {
19476
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9862 times.
9987 nsp(c>35 ? false : random);
19477
3/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 8056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
11918 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19478
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19479
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931 times.
✗ Branch 3 not taken.
1931 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19480
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
1931 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19481 1931 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19482
19483
2/2
✓ Branch 0 taken 9986 times.
✓ Branch 1 taken 1 times.
9987 if(++c>50)
19484 1 return -1;
19485
2/2
✓ Branch 0 taken 8055 times.
✓ Branch 1 taken 1931 times.
9986 }
19486 9986 while(blocked);
19487
19488 1931 int32_t dir=0;
19489
19490
2/2
✓ Branch 0 taken 1354 times.
✓ Branch 1 taken 577 times.
1931 if(sle_x==0) dir=right;
19491
19492
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 501 times.
1931 if(sle_y==0) dir=down;
19493
19494
2/2
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 542 times.
1931 if(sle_x==240) dir=left;
19495
19496
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(sle_y==168) dir=up;
19497
19498 1931 return dir;
19499 1932 }
19500
19501 bool can_side_load(int32_t id)
19502 {
19503 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19504 {
19505 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
19506 return false;
19507 }
19508 switch(guysbuf[id].family) //id&0x0FFF)
19509 {
19510 //case eTEK1:
19511 //case eTEK2:
19512 //case eTEK3:
19513 //case eLEV1:
19514 //case eLEV2:
19515 //case eLEV3:
19516 //case eRAQUAM:
19517 //case eLAQUAM:
19518 //case eDODONGO:
19519 //case eMANHAN:
19520 //case eGLEEOK1:
19521 //case eGLEEOK2:
19522 //case eGLEEOK3:
19523 //case eGLEEOK4:
19524 //case eDIG1:
19525 //case eDIG3:
19526 //case eGOHMA1:
19527 //case eGOHMA2:
19528 //case eCENT1:
19529 //case eCENT2:
19530 //case ePATRA1:
19531 //case ePATRA2:
19532 //case eGANON:
19533 //case eMANHAN2:
19534 //case eCEILINGM: later
19535 //case eFLOORM: later
19536 //case ePATRABS:
19537 //case ePATRAL2:
19538 //case ePATRAL3:
19539 //case eGLEEOK1F:
19540 //case eGLEEOK2F:
19541 //case eGLEEOK3F:
19542 //case eGLEEOK4F:
19543 //case eDODONGOBS:
19544 //case eDODONGOF:
19545 //case eGOHMA3:
19546 //case eGOHMA4:
19547 //case eSHOOTMAGIC:
19548 //case eSHOOTROCK:
19549 //case eSHOOTSPEAR:
19550 //case eSHOOTSWORD:
19551 //case eSHOOTFLAME:
19552 //case eSHOOTFLAME2:
19553 //case eSHOOTFBALL:
19554 case eeTEK:
19555 case eeLEV:
19556 case eeAQUA:
19557 case eeDONGO:
19558 case eeMANHAN:
19559 case eeGLEEOK:
19560 case eeDIG:
19561 case eeGHOMA:
19562 case eeLANM:
19563 case eePATRA:
19564 case eeGANON:
19565 case eePROJECTILE:
19566 return false;
19567 break;
19568 }
19569
19570 return true;
19571 }
19572
19573 static bool script_sle = false;
19574 static int32_t sle_pattern = 0;
19575 void script_side_load_enemies()
19576 {
19577 if(script_sle || sle_clk) return;
19578 sle_cnt = 0;
19579 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19580 ++sle_cnt;
19581 script_sle = true;
19582 sle_pattern = tmpscr->pattern;
19583 sle_clk = 0;
19584 }
19585
19586 42952 void side_load_enemies()
19587 {
19588
3/4
✓ Branch 0 taken 42952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 578 times.
42952 if(!script_sle && sle_clk==0)
19589 {
19590 578 sle_pattern = tmpscr->pattern;
19591 578 sle_cnt = 0;
19592 578 int32_t guycnt = 0;
19593 578 int16_t s = (currmap<<7)+currscr;
19594 578 bool beenhere=false;
19595 578 bool reload=true;
19596 578 bool unbeatablereload = true;
19597
19598 578 load_default_enemies();
19599
19600
2/2
✓ Branch 0 taken 3468 times.
✓ Branch 1 taken 578 times.
4046 for(int32_t i=0; i<6; i++)
19601
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 178 times.
3646 if(visited[i]==s)
19602 178 beenhere=true;
19603
19604
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 400 times.
578 if(!beenhere)
19605 {
19606 400 visited[vhead]=s;
19607 400 vhead = (vhead+1)%6;
19608 400 }
19609
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 39 times.
178 else if(game->guys[s]==0)
19610 {
19611 39 sle_cnt=0;
19612 39 reload=false;
19613 39 }
19614
19615
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 539 times.
578 if(reload)
19616 {
19617 539 sle_cnt = game->guys[s];
19618
19619
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✓ Branch 2 taken 362 times.
✓ Branch 3 taken 177 times.
539 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19620 539 || sle_cnt==0)
19621 {
19622
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 177 times.
983 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19623 806 ++sle_cnt;
19624 177 }
19625
3/4
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 400 times.
✗ Branch 3 not taken.
539 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19626 {
19627 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19628 {
19629 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
19630 {
19631 unbeatablereload = false;
19632 }
19633 }
19634 if (unbeatablereload)
19635 {
19636 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19637 {
19638 ++sle_cnt;
19639 }
19640 }
19641 }
19642 539 }
19643
19644
2/4
✓ Branch 0 taken 578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 578 times.
578 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19645 {
19646 sle_cnt = 0;
19647
19648 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19649 ++sle_cnt;
19650 }
19651
19652
2/2
✓ Branch 0 taken 1889 times.
✓ Branch 1 taken 578 times.
2467 for(int32_t i=0; i<sle_cnt; i++)
19653 1889 ++guycnt;
19654
19655 578 game->guys[s] = guycnt;
19656 578 }
19657
19658
2/2
✓ Branch 0 taken 41020 times.
✓ Branch 1 taken 1932 times.
42952 if((++sle_clk+8)%24 == 0)
19659 {
19660 1932 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19661
19662
4/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 1739 times.
1932 if(dir==-1 || tooclose(sle_x,sle_y,32))
19663 {
19664 193 return;
19665 }
19666
19667 1739 int32_t enemy_slot=guys.Count();
19668
19669
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1739 times.
1739 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19670 sle_cnt--;
19671
19672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(sle_cnt > 0)
19673 {
19674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19675 {
19676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19677 {
19678 1739 guys.spr(enemy_slot)->dir = dir;
19679 1739 }
19680
1/2
✓ Branch 0 taken 1739 times.
✗ Branch 1 not taken.
1739 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19681 {
19682 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19683 {
19684 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19685 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19686 }
19687 }
19688 1739 }
19689 1739 }
19690 1739 }
19691
19692
2/2
✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 511 times.
42759 if(sle_cnt<=0)
19693 {
19694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
511 if(script_sle)
19695 script_sle = false;
19696 511 else loaded_enemies=true;
19697 511 sle_clk = 0;
19698 511 }
19699 42952 }
19700
19701 1125376 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19702 {
19703
19704
4/4
✓ Branch 0 taken 1025602 times.
✓ Branch 1 taken 99774 times.
✓ Branch 2 taken 99774 times.
✓ Branch 3 taken 1125376 times.
1125376 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19705 {
19706 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
19707 199548 return false; //never 0, never OoB.
19708 }
19709 // No corner enemies
19710
6/6
✓ Branch 0 taken 964629 times.
✓ Branch 1 taken 160747 times.
✓ Branch 2 taken 38801 times.
✓ Branch 3 taken 1003430 times.
✓ Branch 4 taken 110860 times.
✓ Branch 5 taken 88688 times.
1125376 if((x==0 || x==240) && (y==0 || y==160))
19711
19712 199548 return false;
19713
19714 //Is a no spawn combo...
19715
3/4
✓ Branch 0 taken 1003426 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1003426 times.
1003430 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19716 4 return false;
19717
19718 // No enemies in dungeon walls
19719
10/10
✓ Branch 0 taken 632806 times.
✓ Branch 1 taken 370620 times.
✓ Branch 2 taken 561286 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 489766 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 403942 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 318118 times.
1003426 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19720 314688 return false;
19721
19722 // Too close
19723
4/4
✓ Branch 0 taken 69962 times.
✓ Branch 1 taken 618776 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 69939 times.
688738 if(tooclose(x,y,40) && t<11)
19724 69939 return false;
19725
19726 // Can't fly onto it?
19727
4/4
✓ Branch 0 taken 115623 times.
✓ Branch 1 taken 503176 times.
✓ Branch 2 taken 34519 times.
✓ Branch 3 taken 16220 times.
669538 if(isflier(tmpscr->enemy[i])&&
19728
2/2
✓ Branch 0 taken 115367 times.
✓ Branch 1 taken 256 times.
115623 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19729
2/2
✓ Branch 0 taken 50739 times.
✓ Branch 1 taken 64628 times.
115367 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19730 16476 return false;
19731
19732 // Can't jump onto it?
19733 if
19734 (
19735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84754 times.
687077 guysbuf[tmpscr->enemy[i]].family==eeTEK
19736
19737
2/2
✓ Branch 0 taken 84754 times.
✓ Branch 1 taken 517569 times.
602323 &&
19738 (
19739
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19740
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOENEMY||
19741
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 ispitfall(x+8,y+8)||
19742
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 MAPFLAG(x+8,y+8)==mfNOENEMY||
19743 84754 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19744 )
19745 )
19746 {
19747 return false;
19748 }
19749
19750 // Other off-limit combos
19751
6/6
✓ Branch 0 taken 503176 times.
✓ Branch 1 taken 99147 times.
✓ Branch 2 taken 418422 times.
✓ Branch 3 taken 84754 times.
✓ Branch 4 taken 239151 times.
✓ Branch 5 taken 179271 times.
1020745 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19752
2/2
✓ Branch 0 taken 242814 times.
✓ Branch 1 taken 175608 times.
418422 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19753 418422 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19754 179271 return false;
19755
19756 // Don't ever generate enemies on these combos!
19757
3/4
✓ Branch 0 taken 422753 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422753 times.
423052 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19758 299 return false;
19759
19760 //BS Dodongos need at least 2 spaces.
19761
4/4
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 421789 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 2 times.
422753 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
19762 {
19763
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19764 ((x>224)||_walkflag(x+16,y+8, 2))&&
19765 ((y<16) ||_walkflag(x, y-8, 2))&&
19766 ((y>144)||_walkflag(x, y+24,2)))
19767 {
19768 return false;
19769 }
19770 2 }
19771
19772 422753 return true;
19773 1025602 }
19774
19775 79304 bool is_ceiling_pattern(int32_t i)
19776 {
19777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79304 times.
79304 return (i==pCEILING || i==pCEILINGR);
19778 }
19779
19780 5543 int32_t placeenemy(int32_t i)
19781 {
19782 5543 std::map<int32_t, int32_t> freeposcache;
19783 5543 int32_t frees = 0;
19784
19785
2/2
✓ Branch 0 taken 60973 times.
✓ Branch 1 taken 5543 times.
66516 for(int32_t y=0; y<176; y+=16)
19786 {
19787
2/2
✓ Branch 0 taken 975568 times.
✓ Branch 1 taken 60973 times.
1036541 for(int32_t x=0; x<256; x+=16)
19788 {
19789
3/4
✓ Branch 0 taken 975568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 391343 times.
✓ Branch 3 taken 584225 times.
975568 if(is_starting_pos(i,x,y,0))
19790 {
19791
1/2
✓ Branch 0 taken 391343 times.
✗ Branch 1 not taken.
391343 freeposcache[frees++] = (y&0xF0)+(x>>4);
19792 391343 }
19793 975568 }
19794 60973 }
19795
19796
2/2
✓ Branch 0 taken 5532 times.
✓ Branch 1 taken 11 times.
5543 if(frees > 0)
19797
2/4
✓ Branch 0 taken 5532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5532 times.
✗ Branch 3 not taken.
5532 return freeposcache[zc_oldrand()%frees];
19798
19799 11 return -1;
19800 5543 }
19801
19802 39969 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19803 {
19804 39969 bool placed=false;
19805 39969 int32_t t=-1;
19806
19807 // First: enemy combo flags
19808
2/2
✓ Branch 0 taken 424419 times.
✓ Branch 1 taken 36953 times.
461372 for(int32_t sy=0; sy<176; sy+=16)
19809 {
19810
2/2
✓ Branch 0 taken 6768453 times.
✓ Branch 1 taken 421403 times.
7189856 for(int32_t sx=0; sx<256; sx+=16)
19811 {
19812 6768453 int32_t cflag = MAPFLAG(sx, sy);
19813 6768453 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19814
19815
2/4
✓ Branch 0 taken 6768453 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6768453 times.
✗ Branch 3 not taken.
6768453 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19816 {
19817 if(!ok2add(tmpscr->enemy[i]))
19818 {
19819 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19820 }
19821 else
19822 {
19823 addenemy(sx,
19824 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19825 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19826
19827 ++guycnt;
19828
19829 placed=true;
19830 goto placed_enemy;
19831 }
19832 }
19833
19834
4/4
✓ Branch 0 taken 6765435 times.
✓ Branch 1 taken 3018 times.
✓ Branch 2 taken 6765435 times.
✓ Branch 3 taken 3018 times.
6768453 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19835 {
19836
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3016 times.
3018 if(!ok2add(tmpscr->enemy[i]))
19837 {
19838
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19839 2 }
19840 else
19841 {
19842 6032 addenemy(sx,
19843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19845
19846 3016 ++guycnt;
19847
19848 3016 placed=true;
19849 3016 goto placed_enemy;
19850 }
19851 2 }
19852 6765437 }
19853 421403 }
19854
19855 // Next: enemy pattern
19856
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 32061 times.
✓ Branch 2 taken 31495 times.
✓ Branch 3 taken 5458 times.
✓ Branch 4 taken 31495 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31495 times.
36953 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19857 {
19858 31495 do
19859 {
19860
19861 // NES positions
19862 50119 pos%=9;
19863 50119 x=stx[loadside][pos];
19864 50119 y=sty[loadside][pos];
19865 50119 ++pos;
19866 50119 ++t;
19867
2/2
✓ Branch 0 taken 18624 times.
✓ Branch 1 taken 31495 times.
81614 }
19868
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 50034 times.
50119 while((t< 20) && !is_starting_pos(i,x,y,t));
19869 31495 }
19870
19871
4/4
✓ Branch 0 taken 31495 times.
✓ Branch 1 taken 5458 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 31410 times.
36953 if(t<0 || t >= 20) // above enemy pattern failed
19872 {
19873 // Final chance: find a random position anywhere onscreen
19874 5543 int32_t randpos = placeenemy(i);
19875
19876
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5532 times.
5543 if(randpos>-1)
19877 {
19878 5532 x=(randpos&15)<<4;
19879 5532 y= randpos&0xF0;
19880 5532 }
19881 else // All opportunities failed - abort
19882 {
19883 11 return;
19884 }
19885 5532 }
19886
19887 {
19888 36942 int32_t c=0;
19889 36942 c=clk;
19890
19891
2/2
✓ Branch 0 taken 5563 times.
✓ Branch 1 taken 31379 times.
36942 if(!slowguy(tmpscr->enemy[i]))
19892 31379 ++fastguys;
19893
2/2
✓ Branch 0 taken 851 times.
✓ Branch 1 taken 4712 times.
5563 else if(fastguys>0)
19894 851 c=-15*(i-fastguys+2);
19895 else
19896 4712 c=-15*(i+1);
19897
19898
4/6
✓ Branch 0 taken 7804 times.
✓ Branch 1 taken 29138 times.
✓ Branch 2 taken 7804 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7804 times.
36942 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19899 {
19900 // Special case for blue leevers
19901
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7802 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
7804 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
19902 2 c=-15*(i+1);
19903 else
19904 7802 c=-15;
19905 7804 }
19906
19907
2/2
✓ Branch 0 taken 36636 times.
✓ Branch 1 taken 306 times.
36942 if(!ok2add(tmpscr->enemy[i]))
19908 {
19909
4/6
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
306 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19910 306 }
19911 else
19912 {
19913
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36636 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19914 {
19915
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
73272 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19916
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
36636 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19917
19918 36636 ++guycnt;
19919 36636 }
19920 }
19921
19922 36942 placed=true;
19923 36942 } // if(t < 20)
19924
19925 placed_enemy:
19926
19927 // I don't like this, but it seems to work...
19928 static bool foundCarrier;
19929
19930
2/2
✓ Branch 0 taken 30369 times.
✓ Branch 1 taken 9589 times.
39958 if(i==0)
19931 9589 foundCarrier=false;
19932
19933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39958 times.
39958 if(placed)
19934 {
19935
4/4
✓ Branch 0 taken 9589 times.
✓ Branch 1 taken 30369 times.
✓ Branch 2 taken 9446 times.
✓ Branch 3 taken 143 times.
39958 if(i==0 && tmpscr->enemyflags&efLEADER)
19936 {
19937 143 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19938
19939
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 7 times.
143 if(index!=-1)
19940 {
19941 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19942
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
136 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(index!=-1)
19944 {
19945 136 ((enemy*)guys.spr(index))->leader = true;
19946 136 }
19947 136 }
19948 143 }
19949
19950
4/4
✓ Branch 0 taken 39858 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 39824 times.
✓ Branch 3 taken 34 times.
39958 if(!foundCarrier && hasitem&(4|2))
19951 {
19952 34 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19953
19954
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
19955 {
19956 34 ((enemy*)guys.spr(index))->itemguy = true;
19957 34 foundCarrier=true;
19958 34 }
19959 34 }
19960 39958 }
19961 39969 }
19962
19963 bool scriptloadenemies()
19964 {
19965 loaded_enemies = true;
19966 if(script_sle || sle_clk) return false;
19967 if(tmpscr->pattern==pNOSPAWN) return false;
19968
19969 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19970 {
19971 script_side_load_enemies();
19972 return true;
19973 }
19974
19975 int32_t pos=zc_oldrand()%9;
19976 int32_t clk=-15,x=0,y=0,fastguys=0;
19977 int32_t i=0,guycnt=0;
19978 int32_t loadcnt = 10;
19979
19980 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19981 {
19982 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19983 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19984 if (guys.Count() > preguycount)
19985 {
19986 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19987 {
19988 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19989 {
19990 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19991 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19992 }
19993 }
19994 }
19995 --clk;
19996 }
19997 return true;
19998 }
19999
20000 7247218 void loadenemies()
20001 {
20002
3/4
✓ Branch 0 taken 7247218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 7204844 times.
7247218 if(script_sle || sle_clk)
20003 {
20004 42374 side_load_enemies();
20005 42374 return;
20006 }
20007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7204844 times.
7204844 if(tmpscr->pattern==pNOSPAWN) return;
20008
2/2
✓ Branch 0 taken 7188636 times.
✓ Branch 1 taken 16208 times.
7204844 if(loaded_enemies)
20009 7188636 return;
20010
20011 // check if it's the dungeon boss and it has been beaten before
20012
4/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15960 times.
✓ Branch 2 taken 178 times.
✓ Branch 3 taken 70 times.
16208 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
20013 {
20014 70 loaded_enemies = true;
20015 70 return;
20016 }
20017
20018
4/4
✓ Branch 0 taken 15801 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 15560 times.
16138 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
20019 {
20020 578 side_load_enemies();
20021 578 return;
20022 }
20023
20024 15560 loaded_enemies=true;
20025
20026 // do enemies that are always loaded
20027 15560 load_default_enemies();
20028
20029 // dungeon basements
20030
20031 static byte dngn_enemy_x[4] = {32,96,144,208};
20032
20033
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 14881 times.
15560 if(currscr>=128)
20034 {
20035
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 if(DMaps[currdmap].flags&dmfCAVES) return;
20036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
20037 {
20038 for(int32_t i=0; i<10; i++)
20039 {
20040 if ( tmpscr->enemy[i] )
20041 {
20042 int32_t preguycount = guys.Count();
20043 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
20044 if (guys.Count() > preguycount)
20045 {
20046 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20047 {
20048 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20049 {
20050 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20051 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20052 }
20053 }
20054 }
20055 }
20056 }
20057 }
20058 else
20059 {
20060
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 340 times.
1700 for(int32_t i=0; i<4; i++)
20061 {
20062 1360 int32_t preguycount = guys.Count();
20063
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 396 times.
1360 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
20064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (guys.Count() > preguycount)
20065 {
20066
1/2
✓ Branch 0 taken 1360 times.
✗ Branch 1 not taken.
1360 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20067 {
20068 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20069 {
20070 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20071 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20072 }
20073 }
20074 1360 }
20075 1360 }
20076 }
20077 340 return;
20078 }
20079
20080 // check if it's been long enough to reload all enemies
20081
20082 14881 int32_t loadcnt = 10;
20083 14881 int16_t s = (currmap<<7)+currscr;
20084 14881 bool beenhere = false;
20085 14881 bool reload = true;
20086 14881 bool unbeatablereload = true;
20087
20088
2/2
✓ Branch 0 taken 89286 times.
✓ Branch 1 taken 14881 times.
104167 for(int32_t i=0; i<6; i++)
20089
2/2
✓ Branch 0 taken 84954 times.
✓ Branch 1 taken 4332 times.
93618 if(visited[i]==s)
20090 4332 beenhere = true;
20091
20092
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 10549 times.
14881 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
20093 {
20094 10549 visited[vhead]=s; //If not, it adds it to the array,
20095 10549 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
20096 10549 }
20097
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 2331 times.
4332 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
20098 {
20099 2331 loadcnt = 0; //It will tell it not to load any enemies,
20100 2331 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
20101 2331 }
20102
20103
2/2
✓ Branch 0 taken 2331 times.
✓ Branch 1 taken 12550 times.
14881 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
20104 {
20105 12550 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
20106
20107
2/4
✓ Branch 0 taken 4249 times.
✓ Branch 1 taken 8301 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12550 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
20108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4249 times.
4249 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
20109 8301 loadcnt = 10; //That means all enemies need to be respawned.
20110
3/4
✓ Branch 0 taken 10549 times.
✓ Branch 1 taken 2001 times.
✓ Branch 2 taken 10549 times.
✗ Branch 3 not taken.
12550 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
20111 {
20112 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
20113 {
20114 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
20115 {
20116 unbeatablereload = false;
20117 }
20118 }
20119 if (unbeatablereload)
20120 {
20121 loadcnt = 10;
20122 }
20123 }
20124 12550 }
20125
20126
4/4
✓ Branch 0 taken 14231 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 14182 times.
14881 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
20127 699 loadcnt = 10; //All enemies also need to be respawned.
20128
20129 14881 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
20130 14881 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
20131 14881 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
20132
20133
4/4
✓ Branch 0 taken 6581 times.
✓ Branch 1 taken 48269 times.
✓ Branch 2 taken 39969 times.
✓ Branch 3 taken 14881 times.
54850 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
20134 {
20135 39969 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
20136 39969 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
20137
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 39652 times.
39969 if (guys.Count() > preguycount)
20138 {
20139
1/2
✓ Branch 0 taken 39652 times.
✗ Branch 1 not taken.
39652 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20140 {
20141 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20142 {
20143 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20144 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20145 }
20146 }
20147 39652 }
20148
20149 39969 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
20150 39969 }
20151
20152 14881 game->guys[s] = guycnt;
20153 //} //if(true)
20154 7247218 }
20155 147 void moneysign()
20156 {
20157 147 additem(48,108,iRupy,ipDUMMY);
20158 // textout(scrollbuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1);
20159 147 set_clip_state(pricesdisplaybuf, 0);
20160 147 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
20161 147 }
20162
20163 1571 void putprices(bool sign)
20164 {
20165
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1565 times.
1571 if(fadeclk > 0) return;
20166 // refresh what's under the prices
20167 // for(int32_t i=5; i<12; i++)
20168 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
20169
20170 1565 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
20171 1565 int32_t step=32;
20172 1565 int32_t x=80;
20173
20174
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 1387 times.
1565 if(prices[2]==0)
20175 {
20176 1387 step<<=1;
20177
20178
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 27 times.
1387 if(prices[1]==0)
20179 {
20180 1360 x=112;
20181 1360 }
20182 1387 }
20183
20184
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 4695 times.
6260 for(int32_t i=0; i<3; i++)
20185 {
20186 // Kind of stupid, but it works: 100000 is used to indicate that an item
20187 // has a price of zero rather than there being no item.
20188 // 100000 isn't a valid price, so this doesn't cause problems.
20189
3/4
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 4003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 692 times.
4695 if(prices[i]!=0 && prices[i]<100000)
20190 {
20191 char buf[8];
20192 692 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
20193
20194 692 int32_t l=(int32_t)strlen(buf);
20195 692 set_clip_state(pricesdisplaybuf, 0);
20196
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 671 times.
692 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
20197 692 }
20198
20199 4695 x+=step;
20200 4695 }
20201 1571 }
20202
20203 // Setting up special rooms
20204 // Also called when the Letter is used successfully.
20205 721 void setupscreen()
20206 {
20207 721 boughtsomething=false;
20208 721 int32_t t=currscr<128?0:1;
20209 721 word str=tmpscr[t].str;
20210
20211 // Prices are already set to 0 in dowarp()
20212
13/15
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 366 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
721 switch(tmpscr[t].room)
20213 {
20214 case rSP_ITEM: // special item
20215 105 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
20216 105 break;
20217
20218 case rINFO: // pay for info
20219 {
20220 14 int32_t count = 0;
20221 14 int32_t base = 88;
20222 14 int32_t step = 5;
20223
20224 14 moneysign();
20225
20226
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 42 times.
56 for(int32_t i=0; i<3; i++)
20227 {
20228
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(QMisc.info[tmpscr[t].catchall].str[i])
20229 {
20230 42 ++count;
20231 42 }
20232 else
20233 break;
20234 42 }
20235
20236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(count)
20237 {
20238
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==1)
20239 {
20240 base = 88+32;
20241 }
20242
20243
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==2)
20244 {
20245 step = 6;
20246 }
20247
20248
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
56 for(int32_t i=0; i < count; i++)
20249 {
20250 42 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
20251 42 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20252 42 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
20253
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(prices[i]==0)
20254 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20255 42 int32_t itemid = current_item_id(itype_wealthmedal);
20256
20257
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(itemid>=0 && prices[i]!=100000)
20258 {
20259 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20260 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20261 else
20262 prices[i]-=itemsbuf[itemid].misc1;
20263 prices[i]=vbound(prices[i], -99999, 0);
20264 if(prices[i]==0)
20265 prices[i]=100000;
20266 }
20267
20268
2/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
20269 prices[i]=-1;
20270 42 }
20271 14 }
20272
20273 14 break;
20274 }
20275
20276 case rMONEY: // secret money
20277 38 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
20278 38 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20279 38 break;
20280
20281 case rGAMBLE: // gambling
20282 7 prices[0]=prices[1]=prices[2]=-10;
20283 7 moneysign();
20284 7 additem(88,89,iRupy,ipMONEY+ipDUMMY);
20285 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20286 7 additem(120,89,iRupy,ipMONEY+ipDUMMY);
20287 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20288 7 additem(152,89,iRupy,ipMONEY+ipDUMMY);
20289 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
20290 7 break;
20291
20292 case rREPAIR: // door repair
20293
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20294 // }
20295 12 repaircharge=tmpscr[t].catchall;
20296 12 break;
20297
20298 case rMUPGRADE: // upgrade magic
20299 1 adjustmagic=true;
20300 1 break;
20301
20302 case rLEARNSLASH: // learn slash attack
20303 2 learnslash=true;
20304 2 break;
20305
20306 case rRP_HC: // heart container or red potion
20307 12 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
20308 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20309 12 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
20310 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20311 12 break;
20312
20313 case rP_SHOP: // potion shop
20314
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
20315 {
20316 12 str=0;
20317 12 break;
20318 }
20319
20320 [[fallthrough]];
20321 case rTAKEONE: // take one
20322 case rSHOP: // shop
20323 {
20324 127 int32_t count = 0;
20325 127 int32_t base = 88;
20326 127 int32_t step = 5;
20327
20328
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 126 times.
127 if(tmpscr[t].room != rTAKEONE)
20329 126 moneysign();
20330
20331 //count and align the stuff
20332
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 363 times.
461 for(int32_t i=0; i<3; ++i)
20333 {
20334
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 29 times.
363 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
20335 {
20336 334 ++count;
20337 334 }
20338 else
20339 {
20340 29 break;
20341 }
20342 334 }
20343
20344
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 18 times.
127 if(count==1)
20345 {
20346 18 base = 88+32;
20347 18 }
20348
20349
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 11 times.
127 if(count==2)
20350 {
20351 11 step = 6;
20352 11 }
20353
20354
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 127 times.
461 for(int32_t i=0; i<count; i++)
20355 {
20356 334 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
20357 334 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20358
20359
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 332 times.
334 if(tmpscr[t].room != rTAKEONE)
20360 {
20361 332 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
20362
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 if(prices[i]==0)
20363 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20364 332 int32_t itemid = current_item_id(itype_wealthmedal);
20365
20366
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
332 if(itemid>=0 && prices[i]!=100000)
20367 {
20368 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20369 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20370 else
20371 prices[i]+=itemsbuf[itemid].misc1;
20372 prices[i]=vbound(prices[i], 0, 99999);
20373 if(prices[i]==0)
20374 prices[i]=100000;
20375 }
20376
20377
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
20378 prices[i]=1;
20379 332 }
20380 334 }
20381
20382 127 break;
20383 }
20384 case rBOTTLESHOP: // bottle shop
20385 {
20386 int32_t count = 0;
20387 int32_t base = 88;
20388 int32_t step = 5;
20389
20390 moneysign();
20391 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
20392 //count and align the stuff
20393 for(int32_t i=0; i<3; ++i)
20394 {
20395 if(bst.fill[count] != 0)
20396 {
20397 ++count;
20398 }
20399 else
20400 {
20401 break;
20402 }
20403 }
20404
20405 if(count==1)
20406 {
20407 base = 88+32;
20408 }
20409
20410 if(count==2)
20411 {
20412 step = 6;
20413 }
20414
20415 for(int32_t i=0; i<count; i++)
20416 {
20417 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
20418 //{ Setup dummy item
20419 item* curItem = ((item*)items.spr(items.Count()-1));
20420 curItem->PriceIndex = i;
20421 newcombo const& cmb = combobuf[bst.comb[i]];
20422 curItem->o_tile = cmb.o_tile;
20423 curItem->o_cset = bst.cset[i];
20424 curItem->cs = curItem->o_cset;
20425 curItem->tile = cmb.o_tile;
20426 curItem->o_speed = cmb.speed;
20427 curItem->o_delay = 0;
20428 curItem->frames = cmb.frames;
20429 curItem->flip = cmb.flip;
20430 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
20431 curItem->pstring = 0;
20432 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
20433 curItem->flash = false;
20434 curItem->twohand = false;
20435 curItem->anim = true;
20436 curItem->hit_width=1;
20437 curItem->hyofs=4;
20438 curItem->hit_height=12;
20439 curItem->script=0;
20440 curItem->txsz=1;
20441 curItem->tysz=1;
20442 //}
20443
20444 prices[i] = bst.price[i];
20445 if(prices[i]==0)
20446 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20447 int32_t itemid = current_item_id(itype_wealthmedal);
20448
20449 if(itemid>=0 && prices[i]!=100000)
20450 {
20451 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20452 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20453 else
20454 prices[i]+=itemsbuf[itemid].misc1;
20455 prices[i]=vbound(prices[i], 0, 99999);
20456 if(prices[i]==0)
20457 prices[i]=100000;
20458 }
20459
20460 if((bst.price[i])>1 && prices[i]<1)
20461 prices[i]=1;
20462 }
20463
20464 break;
20465 }
20466
20467 case rBOMBS: // more bombs
20468 12 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20469 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20470 12 prices[0]=-tmpscr[t].catchall;
20471 12 break;
20472
20473 case rARROWS: // more arrows
20474 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20475 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20476 prices[0]=-tmpscr[t].catchall;
20477 break;
20478
20479 case rSWINDLE: // leave heart container or money
20480 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
20481 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20482 13 prices[0]=-1;
20483 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20484 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20485 13 prices[1]=-tmpscr[t].catchall;
20486 13 break;
20487
20488 }
20489
20490
3/4
✓ Branch 0 taken 709 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 709 times.
721 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20491 {
20492 12 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20493 12 int32_t itemid = current_item_id(itype_wealthmedal);
20494
20495
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itemid >= 0)
20496 {
20497 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20498 prices[i]*=(itemsbuf[itemid].misc1/100.0);
20499 else
20500 prices[i]+=itemsbuf[itemid].misc1;
20501 }
20502
20503
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(tmpscr[t].catchall>1 && prices[i]>-1)
20504 prices[i]=-1;
20505 12 }
20506
20507 721 putprices(false);
20508
20509
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 35 times.
721 if(str)
20510 {
20511 686 donewmsg(str);
20512 686 }
20513 else
20514 {
20515 35 Hero.unfreeze();
20516 }
20517 721 }
20518
20519 // Increments msgptr and returns the control code argument pointed at.
20520 658 word grab_next_argument()
20521 {
20522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658 times.
658 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20523 658 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20524 658 word ret=val;
20525
20526 // If an argument is succeeded by 255, then it's a three-byte argument -
20527 // between 254 and 65535 (or whatever the maximum actually is)
20528
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20529
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20530 {
20531 val=MsgStrings[msgstr].s[msgptr+2];
20532 word next=val;
20533 ret += 254*next;
20534 msgptr+=2;
20535 }
20536
20537 658 return ret;
20538 658 }
20539
20540 enum
20541 {
20542 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20543 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20544
20545 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20546
20547 MNU_DATA_MAX
20548 };
20549 struct menu_choice
20550 {
20551 int32_t x, y;
20552 int32_t pos;
20553 int32_t upos, dpos, lpos, rpos;
20554 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20555 {}
20556 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20557 int32_t dpos, int32_t lpos, int32_t rpos)
20558 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20559 {}
20560 };
20561 static int32_t msg_menu_data[MNU_DATA_MAX];
20562 static bool do_run_menu = false;
20563 bool do_end_str = false;
20564 static bool wait_advance = false;
20565 116 static std::map<int32_t, menu_choice> menu_options;
20566 19294 void clr_msg_data()
20567 {
20568 19294 do_end_str = false;
20569 19294 wait_advance = false;
20570 19294 do_run_menu = false;
20571 19294 menu_options.clear();
20572 19294 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20573 19294 }
20574
20575 static bool doing_name_insert = false;
20576 static char namebuf[9] = {0};
20577 static char* nameptr = NULL;
20578 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20579 bool runMenuCursor()
20580 {
20581 clear_bitmap(msg_menu_bmp_buf);
20582 if(!menu_options.size())
20583 {
20584 msg_menu_data[MNU_CHOSEN] = 0;
20585 return true; //end menu
20586 }
20587 int32_t pos = msg_menu_data[MNU_CHOSEN];
20588 //If the cursor is at an invalid pos, find the first pos >= 0...
20589 if(menu_options.find(pos) == menu_options.end())
20590 {
20591 pos = 0;
20592 while(menu_options.find(pos) == menu_options.end())
20593 ++pos;
20594 }
20595 menu_choice* ch = &menu_options[pos];
20596
20597 bool pressed = true;
20598 if(rUp()) pos = ch->upos;
20599 else if(rDown()) pos = ch->dpos;
20600 else if(rLeft()) pos = ch->lpos;
20601 else if(rRight()) pos = ch->rpos;
20602 else pressed = false;
20603
20604 if(pressed)
20605 msg_menu_data[MNU_TIMER] = 1;
20606
20607 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20608 bool held = false;
20609 if(hold_input)
20610 {
20611 held = true;
20612 if(Up()) pos = ch->upos;
20613 else if(Down()) pos = ch->dpos;
20614 else if(Left()) pos = ch->lpos;
20615 else if(Right()) pos = ch->rpos;
20616 else held = false;
20617 }
20618 //If the cursor is at an invalid pos, find the first pos >= 0...
20619 if(menu_options.find(pos) == menu_options.end())
20620 {
20621 pos = 0;
20622 while(menu_options.find(pos) == menu_options.end())
20623 ++pos;
20624 }
20625 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20626 sfx(MsgStrings[msgstr].sfx);
20627
20628 ch = &menu_options[pos];
20629 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20630 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20631 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20632 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20633
20634 msg_menu_data[MNU_CHOSEN] = pos;
20635
20636 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20637 {
20638 rAbtn(); //Eat
20639 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20640 }
20641
20642 bool ret = (pressed || held) ? false : rAbtn();
20643 //Eat inputs
20644 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20645
20646 if(ret)
20647 menu_options.clear();
20648
20649 return ret;
20650 //false if pos changed this frame; no confirming while moving the cursor!
20651 }
20652
20653 184652 bool bottom_margin_clip()
20654 {
20655 184652 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20656
1/2
✓ Branch 0 taken 184652 times.
✗ Branch 1 not taken.
184652 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20657 }
20658
20659 void update_msgstr();
20660 98310 bool parsemsgcode()
20661 {
20662
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 97710 times.
98310 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20663 97710 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20664
5/38
✗ Branch 0 not taken.
✓ Branch 1 taken 97361 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 310 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
97710 switch(c)
20665 {
20666 case MSGC_NEWLINE:
20667 {
20668 1 ssc_tile_hei = ssc_tile_hei_buf;
20669
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20670 1 ssc_tile_hei_buf = -1;
20671 1 cursor_y += thei + MsgStrings[msgstr].vspace;
20672 1 cursor_x=msg_margins[left];
20673 1 return true;
20674 }
20675
20676 case MSGC_COLOUR:
20677 {
20678 310 int32_t cset = (grab_next_argument());
20679 310 msgcolour = CSET(cset)+(grab_next_argument());
20680 310 return true;
20681 }
20682
20683 case MSGC_SHDCOLOR:
20684 {
20685 int32_t cset = (grab_next_argument());
20686 msg_shdcol = CSET(cset)+(grab_next_argument());
20687 return true;
20688 }
20689 case MSGC_SHDTYPE:
20690 {
20691 msg_shdtype = grab_next_argument();
20692 return true;
20693 }
20694
20695 case MSGC_SPEED:
20696 {
20697 28 msgspeed=grab_next_argument();
20698 28 return true;
20699 }
20700
20701 case MSGC_CTRUP:
20702 {
20703 int32_t a1 = grab_next_argument();
20704 int32_t a2 = grab_next_argument();
20705 game->change_counter(a2, a1);
20706 return true;
20707 }
20708
20709 case MSGC_CTRDN:
20710 {
20711 int32_t a1 = grab_next_argument();
20712 int32_t a2 = grab_next_argument();
20713 game->change_counter(-a2, a1);
20714 return true;
20715 }
20716
20717 case MSGC_CTRSET:
20718 {
20719 int32_t a1 = grab_next_argument();
20720 int32_t a2 = grab_next_argument();
20721 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20722 return true;
20723 }
20724
20725 case MSGC_CTRUPPC:
20726 case MSGC_CTRDNPC:
20727 case MSGC_CTRSETPC:
20728 {
20729 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20730 int32_t counter = grab_next_argument();
20731 int32_t amount = grab_next_argument();
20732 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20733
20734 if(code==MSGC_CTRDNPC)
20735 amount*=-1;
20736
20737 if(code==MSGC_CTRSETPC)
20738 game->set_counter(amount, counter);
20739 else
20740 game->change_counter(amount, counter);
20741
20742 return true;
20743 }
20744
20745 case MSGC_GIVEITEM:
20746 {
20747 int32_t itemID = grab_next_argument();
20748
20749 getitem(itemID, true);
20750 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20751 {
20752 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20753 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) > 0;
20754 }
20755 return true;
20756 }
20757
20758
20759 case MSGC_WARP:
20760 {
20761 int32_t dmap = grab_next_argument();
20762 int32_t scrn = grab_next_argument();
20763 int32_t dx = grab_next_argument();
20764 int32_t dy = grab_next_argument();
20765 int32_t wfx = grab_next_argument();
20766 int32_t sfx = grab_next_argument();
20767 if(dx >= MAX_SCC_ARG) dx = -1;
20768 if(dy >= MAX_SCC_ARG) dy = -1;
20769 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
20770 return true;
20771 }
20772
20773 case MSGC_SETSCREEND:
20774 {
20775 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20776 int32_t screen = grab_next_argument();
20777 int32_t reg = grab_next_argument();
20778 int32_t val = grab_next_argument();
20779 FFCore.set_screen_d(screen + dmap, reg, val);
20780 return true;
20781 }
20782 case MSGC_TAKEITEM:
20783 {
20784 int32_t itemID = grab_next_argument();
20785 if ( FFCore.doscript(ScriptType::Item, itemID) )
20786 {
20787 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20788 }
20789 takeitem(itemID);
20790 if ( game->forced_bwpn == itemID )
20791 {
20792 game->forced_bwpn = -1;
20793 } //not else if! -Z
20794 if ( game->forced_awpn == itemID )
20795 {
20796 game->forced_awpn = -1;
20797 }
20798 if ( game->forced_xwpn == itemID )
20799 {
20800 game->forced_xwpn = -1;
20801 } //not else if! -Z
20802 if ( game->forced_ywpn == itemID )
20803 {
20804 game->forced_ywpn = -1;
20805 }
20806 verifyBothWeapons();
20807 return true;
20808 }
20809
20810 case MSGC_SFX:
20811 {
20812 10 sfx((int32_t)grab_next_argument(),128);
20813 10 return true;
20814 }
20815
20816 case MSGC_MIDI:
20817 {
20818 int32_t music = (int32_t)(grab_next_argument());
20819
20820 if(music==0)
20821 music_stop();
20822 else
20823 jukebox(music+(ZC_MIDI_COUNT-1));
20824
20825 return true;
20826 }
20827
20828 case MSGC_NAME:
20829 {
20830 doing_name_insert = true;
20831 sprintf(namebuf, "%s", game->get_name());
20832 nameptr = namebuf;
20833 return true;
20834 }
20835
20836 case MSGC_FONT:
20837 {
20838 int fontid = grab_next_argument();
20839 int oh = text_height(msgfont);
20840 msgfont = get_zc_font(fontid);
20841 int nh = text_height(msgfont);
20842 int mh = std::max(oh,nh);
20843 if(mh > ssc_tile_hei_buf)
20844 ssc_tile_hei_buf = mh;
20845 return true;
20846 }
20847 case MSGC_RUN_FRZ_GENSCR:
20848 {
20849 word scr_id = grab_next_argument();
20850 bool force_redraw = grab_next_argument()!=0;
20851 if(force_redraw)
20852 {
20853 update_msgstr();
20854 draw_screen(tmpscr);
20855 }
20856 FFCore.runGenericFrozenEngine(scr_id);
20857 return true;
20858 }
20859 case MSGC_DRAWTILE:
20860 {
20861 int32_t tl = grab_next_argument();
20862 int32_t cs = grab_next_argument();
20863 int32_t t_wid = grab_next_argument();
20864 int32_t t_hei = grab_next_argument();
20865 int32_t fl = grab_next_argument();
20866
20867 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20868 {
20869 ssc_tile_hei = ssc_tile_hei_buf;
20870 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20871 ssc_tile_hei_buf = -1;
20872 cursor_y += thei + MsgStrings[msgstr].vspace;
20873 if(bottom_margin_clip()) return true;
20874 cursor_x=msg_margins[left];
20875 }
20876
20877 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20878 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20879 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20880 return true;
20881 }
20882
20883 case MSGC_GOTOIFRAND:
20884 {
20885 int32_t odds = (int32_t)(grab_next_argument());
20886
20887 if(!odds || !(zc_oldrand()%odds))
20888 goto switched;
20889
20890 (void)grab_next_argument();
20891 return true;
20892 }
20893
20894 case MSGC_GOTOIFGLOBAL:
20895 {
20896 int32_t arg = (int32_t)grab_next_argument();
20897 int32_t d = zc_min(7,arg);
20898 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20899 arg = (int32_t)grab_next_argument();
20900
20901 if(game->screen_d[s][d] >= arg)
20902 goto switched;
20903
20904 (void)grab_next_argument();
20905 return true;
20906 }
20907
20908 case MSGC_CHANGEPORTRAIT:
20909 {
20910 return true; //not implemented
20911 }
20912
20913 case MSGC_GOTOIFCREEND:
20914 {
20915 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20916 int32_t screen = grab_next_argument();
20917 int32_t reg = grab_next_argument();
20918 int32_t val = grab_next_argument();
20919 //int32_t nxtstr = grab_next_argument();
20920 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20921 {
20922 goto switched;
20923 }
20924 (void)grab_next_argument();
20925 return true;
20926 }
20927
20928 case MSGC_GOTOIF:
20929 {
20930 int32_t it = (int32_t)grab_next_argument();
20931
20932 if(unsigned(it)<MAXITEMS && game->item[it])
20933 goto switched;
20934
20935 (void)grab_next_argument();
20936 return true;
20937 }
20938
20939 case MSGC_GOTOIFCTR:
20940 {
20941 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20942 goto switched;
20943
20944 (void)grab_next_argument();
20945 return true;
20946 }
20947
20948 case MSGC_GOTOIFCTRPC:
20949 {
20950 int32_t counter = grab_next_argument();
20951 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20952
20953 if(game->get_counter(counter)>=amount)
20954 goto switched;
20955
20956 (void)grab_next_argument();
20957 return true;
20958 }
20959
20960 case MSGC_GOTOIFTRICOUNT:
20961 {
20962 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20963 goto switched;
20964
20965 (void)grab_next_argument();
20966 return true;
20967 }
20968
20969 case MSGC_GOTOIFTRI:
20970 {
20971 int32_t lev = (int32_t)(grab_next_argument());
20972
20973 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20974 goto switched;
20975
20976 (void)grab_next_argument();
20977 return true;
20978 }
20979
20980 case MSGC_SETUPMENU:
20981 {
20982 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20983 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20984 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20985 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20986 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20987 return true;
20988 }
20989
20990 case MSGC_MENUCHOICE:
20991 {
20992 int32_t pos = grab_next_argument();
20993 int32_t upos = grab_next_argument();
20994 int32_t dpos = grab_next_argument();
20995 int32_t lpos = grab_next_argument();
20996 int32_t rpos = grab_next_argument();
20997 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20998 {
20999 ssc_tile_hei = ssc_tile_hei_buf;
21000 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21001 ssc_tile_hei_buf = -1;
21002 cursor_y += thei + MsgStrings[msgstr].vspace;
21003 if(bottom_margin_clip()) break;
21004 cursor_x=msg_margins[left];
21005 }
21006
21007 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
21008 upos, dpos, lpos, rpos);
21009
21010 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
21011 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
21012 return true;
21013 }
21014
21015 case MSGC_RUNMENU:
21016 {
21017 msg_menu_data[MNU_CHOSEN] = 0;
21018 msg_menu_data[MNU_CAN_CONFIRM] = 0;
21019 if(menu_options.size() < 1)
21020 return true;
21021 do_run_menu = true;
21022 return true;
21023 }
21024
21025 case MSGC_GOTOMENUCHOICE:
21026 {
21027 int32_t choice = grab_next_argument();
21028 if(msg_menu_data[MNU_CHOSEN] == choice)
21029 goto switched;
21030 (void)grab_next_argument();
21031 return true;
21032 }
21033
21034 case MSGC_ENDSTRING:
21035 {
21036 do_end_str = true;
21037 return true;
21038 }
21039 case MSGC_WAIT_ADVANCE:
21040 {
21041 wait_advance = true;
21042 linkedmsgclk = 51;
21043 return true;
21044 }
21045 case MSGC_TRIGSECRETS:
21046 {
21047 bool perm = (bool)grab_next_argument();
21048 hidden_entrance(0, true, false, -8);
21049 if(perm)
21050 setmapflag(mSECRET);
21051 return true;
21052 }
21053 case MSGC_SETSCREENSTATE:
21054 {
21055 int32_t flag = int32_t(grab_next_argument());
21056 if(unsigned(flag)>=mMAXIND)
21057 {
21058 Z_error("SCC 133: Flag %d is invalid\n", flag);
21059 return true;
21060 }
21061 bool state = bool(grab_next_argument());
21062 if(state)
21063 setmapflag(1<<flag);
21064 else
21065 unsetmapflag(1<<flag,true);
21066 return true;
21067 }
21068 case MSGC_SETSCREENSTATER:
21069 {
21070 int32_t map = (int32_t)grab_next_argument();
21071 int32_t scrid = (int32_t)grab_next_argument();
21072 if(map < 1 || map > map_count)
21073 {
21074 Z_error("SCC 134: Map %d is invalid\n", map);
21075 return true;
21076 }
21077 if(unsigned(scrid)>=0x80)
21078 {
21079 Z_error("SCC 134: Screen %d is invalid\n", scrid);
21080 return true;
21081 }
21082
21083 int32_t flag = int32_t(grab_next_argument());
21084 if(unsigned(flag)>=mMAXIND)
21085 {
21086 Z_error("SCC 134: Flag %d is invalid\n", flag);
21087 return true;
21088 }
21089 bool state = bool(grab_next_argument());
21090 if(state)
21091 setmapflag(mapind(map,scrid),1<<flag);
21092 else
21093 unsetmapflag(mapind(map,scrid),1<<flag,true);
21094 return true;
21095 }
21096 switched:
21097 int32_t lev = (int32_t)(grab_next_argument());
21098 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
21099 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
21100 {
21101 msgstr=lev;
21102 msgpos=msgptr=0;
21103 msgfont=setmsgfont();
21104 }
21105 else
21106 {
21107 donewmsg(lev);
21108 ssc_tile_hei_buf = -1;
21109 }
21110 msgptr--; // To counteract it being incremented after this routine is called.
21111 putprices(false);
21112 return true;
21113 }
21114
21115 97361 return false;
21116 98310 }
21117
21118 // Wraps the message string... probably.
21119 95879 void wrapmsgstr(char *s3)
21120 {
21121 95879 int32_t j=0;
21122
21123
2/2
✓ Branch 0 taken 9583 times.
✓ Branch 1 taken 86296 times.
95879 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21124 {
21125
2/2
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 7522 times.
9583 if(msgspace)
21126 {
21127 2061 char c = MsgStrings[msgstr].s[msgptr];
21128
4/6
✓ Branch 0 taken 1766 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1766 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1766 times.
✗ Branch 5 not taken.
2061 if(c != ' ' && c >= 32 && c <= 126)
21129 {
21130
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9709 times.
✓ Branch 2 taken 7949 times.
✓ Branch 3 taken 1766 times.
9715 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
21131 {
21132
3/4
✓ Branch 0 taken 7657 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7657 times.
7949 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
21133 7949 }
21134
21135 1766 s3[j] = 0;
21136 1766 msgspace = false;
21137 1766 }
21138 else
21139 {
21140 295 s3[0] = c;
21141 295 s3[1] = 0;
21142 }
21143 2061 }
21144 else
21145 {
21146 7522 s3[0] = MsgStrings[msgstr].s[msgptr];
21147 7522 s3[1] = 0;
21148
21149
2/2
✓ Branch 0 taken 5891 times.
✓ Branch 1 taken 1631 times.
7522 if(s3[0] == ' ') msgspace=true;
21150 }
21151 9583 }
21152 else
21153 {
21154 86296 s3[0] = MsgStrings[msgstr].s[msgptr];
21155 86296 s3[1] = 0;
21156 }
21157 95879 }
21158
21159 // Returns true if the pointer is at a string's
21160 // null terminator or a trailing space
21161 251409 bool atend(char const* str)
21162 {
21163 251409 int32_t i=0;
21164
21165
2/2
✓ Branch 0 taken 1562249 times.
✓ Branch 1 taken 251409 times.
1813658 while(str[i]==' ')
21166 1562249 i++;
21167
21168 251409 return str[i]=='\0';
21169 }
21170
21171 7285981 void putmsg()
21172 {
21173 7285981 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
21174
2/2
✓ Branch 0 taken 259716 times.
✓ Branch 1 taken 7026265 times.
7285981 if(!msgorig) msgorig=msgstr;
21175
21176
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7285981 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7285981 if(wait_advance && linkedmsgclk < 1)
21177 linkedmsgclk = 1;
21178
2/2
✓ Branch 0 taken 7189899 times.
✓ Branch 1 taken 96082 times.
7285981 if(linkedmsgclk>0)
21179 {
21180
2/2
✓ Branch 0 taken 45481 times.
✓ Branch 1 taken 50601 times.
96082 if(linkedmsgclk==1)
21181 {
21182
5/6
✓ Branch 0 taken 45481 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44553 times.
✓ Branch 3 taken 928 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 44469 times.
45481 if(do_end_str||cAbtn()||cBbtn())
21183 {
21184 1012 do_end_str = false;
21185 1012 linkedmsgclk = 0;
21186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1012 times.
1012 if(wait_advance)
21187 {
21188 wait_advance = false;
21189 }
21190 else
21191 {
21192 1012 msgstr=MsgStrings[msgstr].nextstring;
21193 1012 ssc_tile_hei_buf = -1;
21194
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 836 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
1012 if(!msgstr && enqueued_str)
21195 {
21196 msgstr = enqueued_str;
21197 enqueued_str = 0;
21198 }
21199
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 176 times.
1012 if(!msgstr)
21200 {
21201 176 msgfont=get_zc_font(font_zfont);
21202
21203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
176 if(tmpscr->room!=rGRUMBLE)
21204 176 blockpath=false;
21205
21206 176 dismissmsg();
21207 176 goto disappear;
21208 }
21209
21210 836 donewmsg(msgstr);
21211 836 putprices(false);
21212 }
21213 836 }
21214 45305 }
21215 else
21216 {
21217 50601 --linkedmsgclk;
21218 }
21219 95906 }
21220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7285805 times.
7285805 if(wait_advance) return; //Waiting for buttonpress
21221
21222
9/10
✓ Branch 0 taken 7285711 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 258609 times.
✓ Branch 3 taken 7027102 times.
✓ Branch 4 taken 125105 times.
✓ Branch 5 taken 133504 times.
✓ Branch 6 taken 64456 times.
✓ Branch 7 taken 60649 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 64456 times.
7285805 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
21223 {
21224
2/2
✓ Branch 0 taken 194153 times.
✓ Branch 1 taken 7027102 times.
7221255 if(!msgstr)
21225 7027102 msgorig=0;
21226
21227 7221255 msg_active = false;
21228 7221255 return;
21229 }
21230
21231 64550 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21232
21233 char s3[145];
21234 int32_t tlength;
21235
21236 // Bypass the string with the B button!
21237
4/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 64219 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 63258 times.
64550 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
21238 {
21239 //finish writing out the string
21240
4/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 77095 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 75989 times.
77281 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
21241 {
21242
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 58987 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
75989 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
21243 goto breakout; // break out if message speed was changed to non-zero
21244
4/6
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75989 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 75753 times.
75989 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21245 {
21246
1/2
✓ Branch 0 taken 75753 times.
✗ Branch 1 not taken.
75753 if(bottom_margin_clip())
21247 break;
21248
21249 75753 wrapmsgstr(s3);
21250
21251
2/2
✓ Branch 0 taken 20120 times.
✓ Branch 1 taken 55633 times.
75753 if(MsgStrings[msgstr].s[msgptr]==' ')
21252 {
21253 20120 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21254
21255
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1347 times.
21510 if(cursor_x+tlength > (msg_w-msg_margins[right])
21256
5/6
✓ Branch 0 taken 1390 times.
✓ Branch 1 taken 18730 times.
✓ Branch 2 taken 1390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1304 times.
✓ Branch 5 taken 43 times.
20120 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21257 43 ? true : strcmp(s3," ")!=0))
21258 {
21259 1347 ssc_tile_hei = ssc_tile_hei_buf;
21260
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21261 1347 ssc_tile_hei_buf = -1;
21262 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
21263
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
21264 1347 cursor_x=msg_margins[left];
21265 1347 }
21266
21267 20120 char buf[2] = {0};
21268 20120 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21269
21270 20120 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21271
21272 20120 cursor_x+=tlength;
21273 20120 }
21274 else
21275 {
21276 55633 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21277
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 533 times.
56334 if(cursor_x+tlength > (msg_w-msg_margins[right])
21278
5/6
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 54889 times.
✓ Branch 2 taken 701 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
55633 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21279 168 ? true : strcmp(s3," ")!=0))
21280 {
21281 744 ssc_tile_hei = ssc_tile_hei_buf;
21282
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21283 744 ssc_tile_hei_buf = -1;
21284 744 cursor_y += thei + MsgStrings[msgstr].vspace;
21285
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(bottom_margin_clip()) break;
21286 744 cursor_x=msg_margins[left];
21287 744 }
21288
21289 55633 sfx(MsgStrings[msgstr].sfx);
21290
21291 55633 char buf[2] = {0};
21292 55633 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21293
21294 55633 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21295
21296 55633 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21297 55633 cursor_x += MsgStrings[msgstr].hspace;
21298 }
21299
21300 75753 msgpos++;
21301 75753 }
21302
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_run_menu)
21303 {
21304 if(runMenuCursor())
21305 {
21306 do_run_menu = false;
21307 }
21308 else break;
21309 }
21310
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(doing_name_insert)
21311 {
21312 if(*nameptr)
21313 {
21314 if(bottom_margin_clip())
21315 break;
21316
21317 char s3[9] = {0};
21318
21319 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21320 {
21321 strcpy(s3, nameptr);
21322 }
21323 else
21324 {
21325 s3[0] = *nameptr;
21326 s3[1] = 0;
21327 }
21328
21329 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21330
21331 if(cursor_x+tlength > (msg_w-msg_margins[right])
21332 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21333 ? true : strcmp(s3," ")!=0))
21334 {
21335 ssc_tile_hei = ssc_tile_hei_buf;
21336 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21337 ssc_tile_hei_buf = -1;
21338 cursor_y += thei + MsgStrings[msgstr].vspace;
21339 if(bottom_margin_clip()) break;
21340 cursor_x=msg_margins[left];
21341 }
21342
21343 sfx(MsgStrings[msgstr].sfx);
21344
21345 char buf[2] = {0};
21346 sprintf(buf,"%c",*nameptr);
21347
21348 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21349
21350 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21351 cursor_x += MsgStrings[msgstr].hspace;
21352 ++nameptr;
21353 continue; //don't advance the msgptr, as the next char in it was not processed!
21354 }
21355 else doing_name_insert = false;
21356 }
21357 75989 ++msgptr;
21358
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_end_str)
21359 goto strendcheck;
21360
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(wait_advance)
21361 return;
21362
2/2
✓ Branch 0 taken 74810 times.
✓ Branch 1 taken 1179 times.
75989 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21363 {
21364
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 776 times.
1179 if(MsgStrings[msgstr].nextstring)
21365 {
21366
1/2
✓ Branch 0 taken 776 times.
✗ Branch 1 not taken.
776 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21367 {
21368 msgstr=MsgStrings[msgstr].nextstring;
21369 msgpos=msgptr=0;
21370 msgfont=setmsgfont();
21371 }
21372 776 }
21373 1179 }
21374 }
21375
21376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1198 times.
1198 if (!do_run_menu)
21377 {
21378 1198 msgclk = 72;
21379 1198 msgpos = 10000;
21380 1198 }
21381 1198 }
21382 else
21383 63258 {
21384 breakout:
21385 63258 word tempspeed = msgspeed;
21386
1/2
✓ Branch 0 taken 63258 times.
✗ Branch 1 not taken.
63258 if (do_run_menu)
21387 tempspeed = 0;
21388
6/6
✓ Branch 0 taken 52619 times.
✓ Branch 1 taken 10639 times.
✓ Branch 2 taken 15012 times.
✓ Branch 3 taken 37607 times.
✓ Branch 4 taken 10206 times.
✓ Branch 5 taken 4806 times.
63258 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
21389 42413 return;
21390 }
21391
21392 // Start writing the string
21393
2/2
✓ Branch 0 taken 21435 times.
✓ Branch 1 taken 608 times.
22651 if(msgptr == 0)
21394 {
21395
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 2415 times.
3023 while(MsgStrings[msgstr].s[msgptr]==' ')
21396 {
21397 2415 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21398
21399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
2456 if(cursor_x+tlength > (msg_w-msg_margins[right])
21400
4/6
✓ Branch 0 taken 2374 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
2415 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21401 ? 1 : strcmp(s3," ")!=0))
21402 {
21403 41 ssc_tile_hei = ssc_tile_hei_buf;
21404
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21405 41 ssc_tile_hei_buf = -1;
21406 41 cursor_y += thei + MsgStrings[msgstr].vspace;
21407
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(bottom_margin_clip()) break;
21408 41 cursor_x=msg_margins[left];
21409 41 }
21410
21411 2415 cursor_x+=tlength;
21412 2415 ++msgptr;
21413 2415 ++msgpos;
21414
21415 // The "Continue From Previous" feature
21416
2/2
✓ Branch 0 taken 1047 times.
✓ Branch 1 taken 1368 times.
2415 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21417 {
21418
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
21419 {
21420 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21421 {
21422 msgstr=MsgStrings[msgstr].nextstring;
21423 msgpos=msgptr=0;
21424 msgfont=setmsgfont();
21425 }
21426 }
21427 1368 }
21428 }
21429 608 }
21430
21431 reparsesinglechar:
21432 // Continue printing the string!
21433
3/4
✓ Branch 0 taken 20239 times.
✓ Branch 1 taken 1804 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20239 times.
42282 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
21434 {
21435
4/6
✓ Branch 0 taken 20239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113 times.
✓ Branch 5 taken 20126 times.
20239 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21436 {
21437 20126 wrapmsgstr(s3);
21438
21439 20126 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21440
21441
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 236 times.
20380 if(cursor_x+tlength > (msg_w-msg_margins[right])
21442
6/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 19868 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 4 times.
20126 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21443 18 ? true : strcmp(s3," ")!=0))
21444 {
21445 254 ssc_tile_hei = ssc_tile_hei_buf;
21446
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21447 254 ssc_tile_hei_buf = -1;
21448 254 cursor_y += thei + MsgStrings[msgstr].vspace;
21449
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 if(bottom_margin_clip()) goto strendcheck;
21450 254 cursor_x=msg_margins[left];
21451 //if(space) s3[0]=0;
21452 254 }
21453
21454 20126 sfx(MsgStrings[msgstr].sfx);
21455
21456 20126 char buf[2] = {0};
21457 20126 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21458
21459 20126 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21460
21461 20126 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21462 20126 cursor_x += MsgStrings[msgstr].hspace;
21463 20126 msgpos++;
21464 20126 }
21465
1/2
✓ Branch 0 taken 20239 times.
✗ Branch 1 not taken.
20239 if(do_end_str)
21466 goto strendcheck;
21467
1/2
✓ Branch 0 taken 20239 times.
✗ Branch 1 not taken.
20239 if(wait_advance)
21468 {
21469 ++msgptr;
21470 return;
21471 }
21472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20239 times.
20239 else if(do_run_menu)
21473 {
21474 if(runMenuCursor())
21475 {
21476 do_run_menu = false;
21477 ++msgptr;
21478 goto reparsesinglechar;
21479 }
21480 }
21481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20239 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20239 else if(doing_name_insert && *nameptr)
21482 {
21483 char s3[9] = {0};
21484
21485 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21486 {
21487 strcpy(s3, nameptr);
21488 }
21489 else
21490 {
21491 s3[0] = *nameptr;
21492 s3[1] = 0;
21493 }
21494
21495 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21496
21497 if(cursor_x+tlength > (msg_w-msg_margins[right])
21498 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21499 ? true : strcmp(s3," ")!=0))
21500 {
21501 ssc_tile_hei = ssc_tile_hei_buf;
21502 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21503 ssc_tile_hei_buf = -1;
21504 cursor_y += thei + MsgStrings[msgstr].vspace;
21505 if(bottom_margin_clip()) goto strendcheck;
21506 cursor_x=msg_margins[left];
21507 }
21508
21509 sfx(MsgStrings[msgstr].sfx);
21510
21511 char buf[2] = {0};
21512 sprintf(buf,"%c",*nameptr);
21513
21514 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21515
21516 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21517 cursor_x += MsgStrings[msgstr].hspace;
21518 ++nameptr;
21519 }
21520 else
21521 {
21522 20239 doing_name_insert = false;
21523 20239 msgptr++;
21524
21525
2/2
✓ Branch 0 taken 19737 times.
✓ Branch 1 taken 502 times.
20239 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21526 {
21527
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 61 times.
502 if(MsgStrings[msgstr].nextstring)
21528 {
21529
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21530 {
21531 msgstr=MsgStrings[msgstr].nextstring;
21532 msgpos=msgptr=0;
21533 msgfont=setmsgfont();
21534 }
21535 61 }
21536 502 }
21537
21538
2/2
✓ Branch 0 taken 2962 times.
✓ Branch 1 taken 1010 times.
24211 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21539
2/2
✓ Branch 0 taken 20192 times.
✓ Branch 1 taken 47 times.
20239 && (MsgStrings[msgstr].s[msgptr]==' ')
21540
2/2
✓ Branch 0 taken 3972 times.
✓ Branch 1 taken 16220 times.
20192 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21541 {
21542
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 33272 times.
34282 while(MsgStrings[msgstr].s[msgptr]==' ')
21543 {
21544 33272 msgspace = true;
21545 33272 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21546
21547
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1440 times.
34734 if(cursor_x+tlength > (msg_w-msg_margins[right])
21548
4/6
✓ Branch 0 taken 1462 times.
✓ Branch 1 taken 31810 times.
✓ Branch 2 taken 1462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
33272 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21549 22 ? true : strcmp(s3," ")!=0))
21550 {
21551 1462 ssc_tile_hei = ssc_tile_hei_buf;
21552
1/2
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
1462 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21553 1462 ssc_tile_hei_buf = -1;
21554 1462 cursor_y += thei + MsgStrings[msgstr].vspace;
21555
1/2
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
1462 if(bottom_margin_clip()) break;
21556 1462 cursor_x=msg_margins[left];
21557 1462 }
21558
21559 33272 cursor_x+=tlength;
21560 33272 ++msgpos;
21561 33272 ++msgptr;
21562
21563
2/2
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 30022 times.
33272 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21564 {
21565
2/2
✓ Branch 0 taken 25936 times.
✓ Branch 1 taken 4086 times.
30022 if(MsgStrings[msgstr].nextstring)
21566 {
21567
1/2
✓ Branch 0 taken 4086 times.
✗ Branch 1 not taken.
4086 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21568 {
21569 msgstr=MsgStrings[msgstr].nextstring;
21570 msgpos=msgptr=0;
21571 msgfont=setmsgfont();
21572 }
21573 4086 }
21574 30022 }
21575 }
21576 1010 }
21577 }
21578 20239 }
21579 strendcheck:
21580 // Done printing the string
21581
10/14
✓ Branch 0 taken 22043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22043 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22043 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20845 times.
✓ Branch 7 taken 1198 times.
✓ Branch 8 taken 20356 times.
✓ Branch 9 taken 489 times.
✓ Branch 10 taken 20356 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 19961 times.
✓ Branch 13 taken 2082 times.
22043 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21582 {
21583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2082 times.
2082 if(!do_end_str)
21584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2082 times.
2082 while(parsemsgcode()); // Finish remaining control codes
21585
21586 // Go to next string, or make it disappear by going to string 0.
21587
5/6
✓ Branch 0 taken 1245 times.
✓ Branch 1 taken 837 times.
✓ Branch 2 taken 1069 times.
✓ Branch 3 taken 176 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1069 times.
2082 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21588 {
21589 1013 linkedmsgclk=do_end_str?1:51;
21590 1013 }
21591
21592
2/2
✓ Branch 0 taken 1245 times.
✓ Branch 1 taken 837 times.
2082 if(MsgStrings[msgstr].nextstring==0)
21593 {
21594
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 1069 times.
1245 if(!get_qr(qr_MSGDISAPPEAR))
21595 1069 {
21596 disappear:
21597 1245 msg_active = false;
21598 1245 Hero.finishedmsg();
21599 1245 }
21600
21601
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 12 times.
1421 if(repaircharge)
21602 {
21603 // if (get_qr(qr_REPAIRFIX)) {
21604 // fixed_door=true;
21605 // }
21606 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21607 12 repaircharge = 0;
21608 12 }
21609
21610
2/2
✓ Branch 0 taken 1420 times.
✓ Branch 1 taken 1 times.
1421 if(adjustmagic)
21611 {
21612
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_qr(qr_OLD_HALF_MAGIC))
21613 {
21614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
21615 1 game->set_magicdrainrate(1);
21616 1 }
21617 else if(game->get_magicdrainrate() > 1)
21618 {
21619 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21620 }
21621 1 adjustmagic = false;
21622 1 sfx(WAV_SCALE);
21623
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21624 1 }
21625
21626
2/2
✓ Branch 0 taken 1419 times.
✓ Branch 1 taken 2 times.
1421 if(learnslash)
21627 {
21628 2 game->set_canslash(1);
21629 2 learnslash = false;
21630 2 sfx(WAV_SCALE);
21631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21632 2 }
21633 1421 }
21634 2258 }
21635 7285887 }
21636
21637 45297 int32_t message_more_y()
21638 {
21639 //Is the flag ticked, do we really want a message more y larger than 160?
21640
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45283 times.
✓ Branch 2 taken 45297 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45283 times.
✓ Branch 5 taken 14 times.
45297 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21641 45297 msgy+=playing_field_offset;
21642 45297 return msgy;
21643 }
21644
21645 /*** Collision detection & handling ***/
21646
21647 7262748 void clear_script_one_frame_conditions()
21648 {
21649
2/2
✓ Branch 0 taken 21645616 times.
✓ Branch 1 taken 7262748 times.
28908364 for(int32_t j=0; j<guys.Count(); j++)
21650 {
21651 21645616 enemy *e = (enemy*)guys.spr(j);
21652
2/2
✓ Branch 0 taken 367975472 times.
✓ Branch 1 taken 21645616 times.
389621088 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21653 21645616 }
21654 7262748 }
21655
21656 7262604 void check_collisions()
21657 {
21658
2/2
✓ Branch 0 taken 2976391 times.
✓ Branch 1 taken 7262604 times.
10238995 for(int32_t i=0; i<Lwpns.Count(); i++)
21659 {
21660 2976391 weapon *w = (weapon*)Lwpns.spr(i);
21661
21662
8/8
✓ Branch 0 taken 2512055 times.
✓ Branch 1 taken 464336 times.
✓ Branch 2 taken 2103945 times.
✓ Branch 3 taken 408110 times.
✓ Branch 4 taken 2082632 times.
✓ Branch 5 taken 21313 times.
✓ Branch 6 taken 13640 times.
✓ Branch 7 taken 2068992 times.
2976391 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21663 {
21664
2/2
✓ Branch 0 taken 2058309 times.
✓ Branch 1 taken 7445354 times.
9503663 for(int32_t j=0; j<guys.Count(); j++)
21665 {
21666 7445354 enemy *e = (enemy*)guys.spr(j);
21667
21668 7445354 bool didhit = e->hit(w);
21669
2/2
✓ Branch 0 taken 7307623 times.
✓ Branch 1 taken 137731 times.
7445354 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21670 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21671 {
21672 // !(e->stunclk)
21673 137731 int32_t h = e->takehit(w);
21674
2/2
✓ Branch 0 taken 114502 times.
✓ Branch 1 taken 23229 times.
137731 if (h == -1)
21675 {
21676 23229 e->hitby[HIT_BY_LWEAPON] = i+1;
21677 23229 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21678 23229 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21679
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 21566 times.
23229 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21680 1663 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21681 23229 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21682 23229 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21683
21684 23229 }
21685 //we may need to handle this in special cases. -Z
21686
21687 //if h == stun or ignore
21688
21689 //if e->stun > DEFAULT_STUN -1 || !e->stun
21690 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21691 ///! how about: if w->dead != bounce !
21692
21693 // NOT FOR PUBLIC RELEASE
21694 /*if(h==3) //Mirror shield
21695 {
21696 if (w->id==ewFireball || w->id==wRefFireball)
21697 {
21698 w->id=wRefFireball;
21699 switch(e->dir)
21700 {
21701 case up: e->angle += (PI - e->angle) * 2.0; break;
21702 case down: e->angle = -e->angle; break;
21703 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21704 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21705 // TODO: the following. -L.
21706 case l_up: break;
21707 case r_up: break;
21708 case l_down: break;
21709 case r_down: break;
21710 }
21711 }
21712 else
21713 {
21714 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21715 w->dir ^= 1;
21716 if(w->dir&2)
21717 w->flip ^= 1;
21718 else
21719 w->flip ^= 2;
21720 }
21721 w->ignoreHero=false;
21722 }
21723 else*/
21724
2/2
✓ Branch 0 taken 107377 times.
✓ Branch 1 taken 30354 times.
137731 if(h)
21725 {
21726
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30354 if(e->switch_hooked && w->family_class == itype_switchhook)
21727 w->onhit(false, e, -1);
21728 30354 else w->onhit(false, e, h);
21729 30354 }
21730
21731
2/2
✓ Branch 0 taken 135422 times.
✓ Branch 1 taken 2309 times.
137731 if(h==2)
21732 {
21733 2309 break;
21734 }
21735 135422 }
21736
21737
2/2
✓ Branch 0 taken 7434671 times.
✓ Branch 1 taken 8374 times.
7443045 if(w->Dead())
21738 {
21739 8374 break;
21740 }
21741 7434671 }
21742
21743 // Item flags added in 2.55:
21744 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
21745 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21746 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21747 // -V
21748
6/6
✓ Branch 0 taken 1756493 times.
✓ Branch 1 taken 312499 times.
✓ Branch 2 taken 1752017 times.
✓ Branch 3 taken 4476 times.
✓ Branch 4 taken 21925 times.
✓ Branch 5 taken 1730092 times.
2068992 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21749 {
21750 338900 int32_t itype, pitem = w->parentitem;
21751
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 312499 times.
✓ Branch 2 taken 21925 times.
✓ Branch 3 taken 4476 times.
338900 switch(w->id)
21752 {
21753 312499 case wBrang: itype = itype_brang; break;
21754 21925 case wArrow: itype = itype_arrow; break;
21755 case wHookshot:
21756 4476 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21757 4476 break;
21758 }
21759
2/2
✓ Branch 0 taken 334048 times.
✓ Branch 1 taken 4852 times.
338900 if(pitem < 0) pitem = current_item_id(itype);
21760
5/6
✓ Branch 0 taken 4476 times.
✓ Branch 1 taken 334424 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4376 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
338900 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
21761 { //Swap with item
21762 for(int32_t j=0; j<items.Count(); j++)
21763 {
21764 if(items.spr(j)->hit(w))
21765 {
21766 item *theItem = ((item*)items.spr(j));
21767 bool priced = theItem->PriceIndex >-1;
21768 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21769 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21770 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21771 {
21772 if(!Hero.switchhookclk)
21773 {
21774 hooked_combopos = -1;
21775 hooked_layerbits = 0;
21776 switching_object = theItem;
21777 theItem->switch_hooked = true;
21778 w->misc = 2;
21779 w->step = 0;
21780 theItem->clk2=256;
21781 Hero.doSwitchHook(game->get_switchhookstyle());
21782 if(QMisc.miscsfx[sfxSWITCHED])
21783 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21784 }
21785 }
21786 }
21787 }
21788 }
21789
6/6
✓ Branch 0 taken 21925 times.
✓ Branch 1 taken 316975 times.
✓ Branch 2 taken 318320 times.
✓ Branch 3 taken 296395 times.
✓ Branch 4 taken 316975 times.
✓ Branch 5 taken 296395 times.
338900 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21790 {
21791
2/2
✓ Branch 0 taken 73578 times.
✓ Branch 1 taken 318320 times.
391898 for(int32_t j=0; j<items.Count(); j++)
21792 {
21793
2/2
✓ Branch 0 taken 69398 times.
✓ Branch 1 taken 4180 times.
73578 if(items.spr(j)->hit(w))
21794 {
21795 4180 item *theItem = ((item*)items.spr(j));
21796 4180 bool priced = theItem->PriceIndex >-1;
21797
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 4096 times.
4180 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21798
5/8
✓ Branch 0 taken 4180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3363 times.
✓ Branch 5 taken 817 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1858 times.
6038 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21799
4/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 1858 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
4180 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
21800 {
21801
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
5221 if(itemsbuf[theItem->id].collect_script)
21802 {
21803 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21804 }
21805
21806 1505 Hero.checkitems(j);
21807 1505 }
21808 4180 }
21809 73578 }
21810 318320 }
21811
2/2
✓ Branch 0 taken 4872 times.
✓ Branch 1 taken 15708 times.
613370 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21812 {
21813
2/2
✓ Branch 0 taken 3337 times.
✓ Branch 1 taken 15708 times.
19045 for(int32_t j=0; j<items.Count(); j++)
21814 {
21815
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 935 times.
3337 if(items.spr(j)->hit(w))
21816 {
21817 935 item *theItem = ((item*)items.spr(j));
21818 935 bool priced = theItem->PriceIndex >-1;
21819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21820
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21821
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21822 {
21823 559 int32_t pickup = theItem->pickup;
21824 559 int32_t id2 = theItem->id;
21825 559 int32_t pstr = theItem->pstring;
21826 559 int32_t pstr_flags = theItem->pickup_string_flags;
21827
21828 559 std::vector<int32_t> &ev = FFCore.eventData;
21829 559 ev.clear();
21830 559 ev.push_back(id2*10000);
21831 559 ev.push_back(pickup*10000);
21832 559 ev.push_back(pstr*10000);
21833 559 ev.push_back(pstr_flags*10000);
21834 559 ev.push_back(0);
21835 559 ev.push_back(theItem->getUID());
21836 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21837 559 ev.push_back(w->getUID());
21838
21839 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21840 559 bool nullify = ev[4] != 0;
21841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
21842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
21843 {
21844 559 w->onhit(false);
21845 559 }
21846
21847
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
21848 {
21849 37 w->dead=1;
21850 37 theItem->clk2=256;
21851 37 w->dragging=j;
21852 37 theItem->is_dragged = true;
21853 37 }
21854 559 }
21855 935 }
21856 3337 }
21857 15708 }
21858 338900 }
21859 2068992 }
21860 2976391 }
21861 7262604 }
21862
21863 7262748 void dragging_item()
21864 {
21865
2/2
✓ Branch 0 taken 3037770 times.
✓ Branch 1 taken 7262748 times.
10300518 for(int32_t i=0; i<Lwpns.Count(); i++)
21866 {
21867 3037770 weapon *w = (weapon*)Lwpns.spr(i);
21868
21869
4/4
✓ Branch 0 taken 2718872 times.
✓ Branch 1 taken 318898 times.
✓ Branch 2 taken 3021723 times.
✓ Branch 3 taken 16047 times.
3037770 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
21870 {
21871
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16047 if(w->dragging>=0 && w->dragging<items.Count())
21872 {
21873 551 item* dragItem = (item*)items.spr(w->dragging);
21874 551 dragItem->x=w->x;
21875 551 dragItem->y=w->y;
21876
21877 // Drag the Fairy enemy as well as the Fairy item
21878 551 int32_t id = dragItem->id;
21879
21880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21881 {
21882 movefairynew2(w->x,w->y,*dragItem);
21883 }
21884 551 }
21885 16047 }
21886 3037770 }
21887 7262748 }
21888
21889 28 int32_t more_carried_items()
21890 {
21891 28 int32_t hasmorecarries = 0;
21892
21893
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 28 times.
59 for(int32_t i=0; i<items.Count(); i++)
21894 {
21895
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 28 times.
31 if(((item*)items.spr(i))->pickup & ipENEMY)
21896 {
21897 28 hasmorecarries++;
21898 28 }
21899 31 }
21900
21901 28 return hasmorecarries;
21902 }
21903
21904 // messy code to do the enemy-carrying-the-item thing
21905 7262748 void roaming_item()
21906 {
21907
4/4
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 7249510 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 13198 times.
7262748 if(!(hasitem&(4|2)) || !loaded_enemies)
21908 7249550 return;
21909
21910 // All enemies already dead upon entering a room?
21911
1/2
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
13198 if(guys.Count()==0)
21912 {
21913 return;
21914 }
21915
21916 // Lost track of the carrier?
21917
5/6
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13196 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 13187 times.
✓ Branch 5 taken 9 times.
13198 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21918 13196 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21919 {
21920 11 guycarryingitem=-1;
21921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 for(int32_t j=0; j<guys.Count(); j++)
21922 {
21923
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(((enemy*)guys.spr(j))->itemguy)
21924 {
21925 11 guycarryingitem=j;
21926 11 break;
21927 }
21928 24 }
21929 11 }
21930
21931
2/2
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 34 times.
13198 if(hasitem&4)
21932 {
21933 34 guycarryingitem = -1;
21934
21935
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 34 times.
263 for(int32_t i=0; i<guys.Count(); i++)
21936 {
21937
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 34 times.
229 if(((enemy*)guys.spr(i))->itemguy)
21938 {
21939 34 guycarryingitem = i;
21940 34 }
21941 229 }
21942
21943
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(guycarryingitem == -1) //This happens when "default enemies" such as
21944 {
21945 return; //eSHOOTFBALL are alive but enemies from the list
21946 } //are not. Defer to HeroClass::checkspecial().
21947
21948 34 int32_t Item=tmpscr->item;
21949
21950 34 hasitem &= ~4;
21951
21952
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21953 {
21954 60 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21955
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 8 times.
34 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21956 );
21957 34 hasitem |= 2;
21958 34 }
21959 else
21960 {
21961 return;
21962 }
21963 34 }
21964
21965
2/2
✓ Branch 0 taken 13953 times.
✓ Branch 1 taken 13198 times.
27151 for(int32_t i=0; i<items.Count(); i++)
21966 {
21967
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 13198 times.
13953 if(((item*)items.spr(i))->pickup&ipENEMY)
21968 {
21969
2/2
✓ Branch 0 taken 8390 times.
✓ Branch 1 taken 4808 times.
13198 if(get_qr(qr_HIDECARRIEDITEMS))
21970 {
21971 8390 items.spr(i)->x = -128; // Awfully inelegant, innit?
21972 8390 items.spr(i)->y = -128;
21973 8390 }
21974
2/4
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4808 times.
4808 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21975 {
21976
1/2
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
4808 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21977 {
21978 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21979 {
21980 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21981 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21982 }
21983 else
21984 {
21985 if(guys.spr(guycarryingitem)->extend >= 3)
21986 {
21987 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21988 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21989 }
21990 else
21991 {
21992 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21993 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21994 }
21995 }
21996 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21997 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21998 }
21999 else
22000 {
22001 4808 items.spr(i)->x = guys.spr(guycarryingitem)->x;
22002 4808 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
22003 4808 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
22004 }
22005 4808 }
22006 13198 }
22007 13953 }
22008 7262748 }
22009
22010 bool enemy::IsBigAnim()
22011 {
22012 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
22013 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
22014 || anim == a4FRM8DIRB);
22015 }
22016
22017 const char *old_guy_string[OLDMAXGUYS] =
22018 {
22019 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
22020 // 020
22021 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
22022 // 025
22023 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
22024 // 030
22025 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
22026 // 035
22027 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
22028 // 040
22029 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
22030 // 045
22031 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
22032 // 050
22033 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
22034 // 055
22035 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
22036 // 060
22037 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
22038 // 065
22039 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
22040 // 070
22041 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
22042 // 075
22043 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
22044 // 080
22045 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
22046 // 085
22047 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
22048 // 090
22049 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
22050 // 095
22051 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
22052 // 100
22053 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
22054 // 105
22055 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
22056 // 110
22057 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
22058 // 115
22059 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
22060 // 120
22061 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
22062 // 125
22063 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
22064 // 130
22065 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
22066 // 135
22067 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
22068 // 140
22069 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
22070 // 145
22071 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
22072 // 150
22073 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
22074 // 155
22075 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
22076 // 160
22077 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
22078 // 165
22079 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
22080 // 170
22081 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
22082 // 175
22083 "Grappler Bug (HP) ", "Grappler Bug (MP) "
22084 };
22085